def _phased_x_or_pauli_gate(
    exponent: float | sympy.Expr, phase_exponent: float | sympy.Expr, atol: float
) -> cirq.PhasedXPowGate | cirq.XPowGate | cirq.YPowGate:
    """Return PhasedXPowGate or X or Y gate if equivalent within atol in z-axis turns."""
    if not isinstance(phase_exponent, sympy.Expr) or phase_exponent.is_constant():
        half_turns = value.canonicalize_half_turns(float(phase_exponent))
        if abs(half_turns / 2) <= atol:
            return ops.XPowGate(exponent=exponent)
        if abs((half_turns - 0.5) / 2) <= atol:
            return ops.YPowGate(exponent=exponent)
    return ops.PhasedXPowGate(exponent=exponent, phase_exponent=phase_exponent)
Return PhasedXPowGate or X or Y gate if equivalent within atol in z-axis turns.
cirq-core/cirq/transformers/eject_phased_paulis.py