docs: def _base_iterator(
          self,
          circuit: circuits.Circuit,
          qubit_order: ops.QubitOrderOrList,
          initial_state: Union[int, np.ndarray],
          perform_measurements: bool=True,
      ) -> Iterator['XmonStepResult']:
          """See definition in `cirq.SimulatesIntermediateState`.
  
          If the initial state is an int, the state is set to the computational
          basis state corresponding to this state. Otherwise  if the initial
          state is a np.ndarray it is the full initial state. In this case it
          must be the correct size, be normalized (an L2 norm of 1), and
          be safely castable to an appropriate dtype for the simulator.
          """
          qubits = ops.QubitOrder.as_qubit_order(qubit_order).order_for(
              circuit.all_qubits())
          qubit_map = {q: i for i, q in enumerate(reversed(qubits))}
          if isinstance(initial_state, np.ndarray):
              initial_state = initial_state.astype(dtype=np.complex64,
                                                   casting='safe')
  
          with xmon_stepper.Stepper(
              num_qubits=len(qubits),
              num_prefix_qubits=self.options.num_prefix_qubits,
              initial_state=initial_state,
              min_qubits_before_shard=self.options.min_qubits_before_shard,
              use_processes=self.options.use_processes
          ) as stepper:
              if len(circuit) == 0:
                  yield XmonStepResult(stepper, qubit_map, {})
              for moment in circuit:
                  measurements = collections.defaultdict(
                      list)  # type: Dict[str, List[bool]]
                  phase_map = {}  # type: Dict[Tuple[int, ...], float]
                  for op in moment.operations:
                      gate = cast(ops.GateOperation, op).gate
                      if isinstance(gate, ops.ZPowGate):
                          index = qubit_map[op.qubits[0]]
                          phase_map[(index,)] = cast(float, gate.exponent)
                      elif isinstance(gate, ops.CZPowGate):
                          index0 = qubit_map[op.qubits[0]]
                          index1 = qubit_map[op.qubits[1]]
                          phase_map[(index0, index1)] = cast(float,
                                                             gate.exponent)
                      elif isinstance(gate, ops.XPowGate):
                          index = qubit_map[op.qubits[0]]
                          stepper.simulate_w(
                              index=index,
                              half_turns=gate.exponent,
                              axis_half_turns=0)
                      elif isinstance(gate, ops.YPowGate):
                          index = qubit_map[op.qubits[0]]
                          stepper.simulate_w(
                              index=index,
                              half_turns=gate.exponent,
                              axis_half_turns=0.5)
                      elif isinstance(gate, ops.PhasedXPowGate):
                          index = qubit_map[op.qubits[0]]
                          stepper.simulate_w(
                              index=index,
                              half_turns=gate.exponent,
                              axis_half_turns=gate.phase_exponent)
                      elif isinstance(gate, ops.MeasurementGate):
                          if perform_measurements:
                              invert_mask = (
                                  gate.invert_mask or len(op.qubits) * (False,))
                              for qubit, invert in zip(op.qubits, invert_mask):
                                  index = qubit_map[qubit]
                                  result = stepper.simulate_measurement(index)
                                  if invert:
                                      result = not result
                                  key = protocols.measurement_key(gate)
                                  measurements[key].append(result)
                      else:
                          # coverage: ignore
                          raise TypeError('{!r} is not supported by the '
                                          'xmon simulator.'.format(gate))
                  stepper.simulate_phases(phase_map)
                  yield XmonStepResult(stepper, qubit_map, measurements)