code: def _pick_inserted_ops_moment_indices(operations: Sequence[ops.Operation],
                                            start: int = 0,
                                            frontier: Dict[ops.Qid,
                                                           int] = None
                                            ) -> Tuple[Sequence[int],
                                                       Dict[ops.Qid, int]]:
          
          if frontier is None:
              frontier = defaultdict(lambda: 0)
          moment_indices = []
          for op in operations:
              op_start = max(start, max(frontier[q] for q in op.qubits))
              moment_indices.append(op_start)
              for q in op.qubits:
                  frontier[q] = max(frontier[q], op_start + 1)
  
          return moment_indices, frontier
docs: Greedily assigns operations to moments.
  
          Args:
              operations: The operations to assign to moments.
              start: The first moment to consider assignment to.
              frontier: The first moment to which an operation acting on a qubit
                  can be assigned. Updated in place as operations are assigned.
  
          Returns:
              The frontier giving the index of the moment after the last one to
              which an operation that acts on each qubit is assigned. If a
              frontier was specified as an argument, this is the same object.