def factor(
        self, qubits: Sequence[cirq.Qid], *, validate=True, atol=1e-07, inplace=False
    ) -> tuple[Self, Self]:
        """Splits two state spaces after a measurement or reset."""
        extracted = copy.copy(self)
        remainder = self if inplace else copy.copy(self)
        e, r = self._state.factor(self.get_axes(qubits), validate=validate, atol=atol)
        extracted._state = e
        remainder._state = r
        extracted._set_qubits(qubits)
        remainder._set_qubits([q for q in self.qubits if q not in qubits])
        return extracted, remainder
Splits two state spaces after a measurement or reset.
cirq-core/cirq/sim/simulation_state.py