def _get_constant_gauge(
        self, gate: ops.CZPowGate, pre_q0: ops.Gate, pre_q1: ops.Gate
    ) -> ConstantGauge:
        """Get the ConstantGauge corresponding to a given pre_q0 and pre_q1.

        Args:
            gate: The particular cphase gate to transform.
            pre_q0: The Pauli (I, X, Y, or Z) to insert before the cphase gate on q0.
            pre_q1: The Pauli (I, X, Y, or Z) to insert before the cphase gate on q1.

        Returns:
            The ConstantGauge implementing the given transformation.

        Raises:
            ValueError: If pre_q0 and pre_q1 are not both in {I, X, Y, Z}.
        """

        exponent = gate.exponent
        commuting_paulis = {ops.I, ops.Z}
        anticommuting_paulis = {ops.X, ops.Y}
        if pre_q0 in commuting_paulis and pre_q1 in commuting_paulis:
            return ConstantGauge(
                two_qubit_gate=gate, pre_q0=pre_q0, pre_q1=pre_q1, post_q0=pre_q0, post_q1=pre_q1
            )
        elif pre_q0 in anticommuting_paulis and pre_q1 in commuting_paulis:
            new_gate = ops.CZ ** (-exponent)
            post_q1 = ops.Z ** (exponent) if pre_q1 == ops.I else ops.Z ** (1 + exponent)
            return ConstantGauge(
                two_qubit_gate=new_gate,
                pre_q0=pre_q0,
                pre_q1=pre_q1,
                post_q0=pre_q0,
                post_q1=post_q1,
            )
        elif pre_q0 in commuting_paulis and pre_q1 in anticommuting_paulis:
            new_gate = ops.CZ ** (-exponent)
            post_q0 = ops.Z ** (exponent) if pre_q0 == ops.I else ops.Z ** (1 + exponent)
            return ConstantGauge(
                two_qubit_gate=new_gate,
                pre_q0=pre_q0,
                pre_q1=pre_q1,
                post_q0=post_q0,
                post_q1=pre_q1,
            )
        elif pre_q0 in anticommuting_paulis and pre_q1 in anticommuting_paulis:
            return ConstantGauge(
                two_qubit_gate=gate,
                pre_q0=pre_q0,
                pre_q1=pre_q1,
                post_q0=self._get_new_post(exponent, pre_q0),
                post_q1=self._get_new_post(exponent, pre_q1),
            )
        else:
            raise ValueError("pre_q0 and pre_q1 should be X, Y, Z, or I")  # pragma: no cover
Get the ConstantGauge corresponding to a given pre_q0 and pre_q1.

        Args:
            gate: The particular cphase gate to transform.
            pre_q0: The Pauli (I, X, Y, or Z) to insert before the cphase gate on q0.
            pre_q1: The Pauli (I, X, Y, or Z) to insert before the cphase gate on q1.

        Returns:
            The ConstantGauge implementing the given transformation.

        Raises:
            ValueError: If pre_q0 and pre_q1 are not both in {I, X, Y, Z}.
        
cirq-core/cirq/transformers/gauge_compiling/cphase_gauge.py