def __init__(
        self, *, exponent: value.TParamVal = 1.0, global_shift: float = 0.0  # Forces keyword args.
    ) -> None:
        """Initializes the parameters used to compute the gate's matrix.

        Args:
            exponent: The t in gate**t. Determines how much the eigenvalues of
                the gate are phased by. For example, eigenvectors phased by -1
                when `gate**1` is applied will gain a relative phase of
                e^{i pi exponent} when `gate**exponent` is applied (relative to
                eigenvectors unaffected by `gate**1`).
            global_shift: Offsets the eigenvalues of the gate at exponent=1.
                In effect, this controls a global phase factor on the gate's
                unitary matrix. The factor is:

                    exp(i * pi * global_shift * exponent)

                For example, `cirq.X**t` uses a `global_shift` of 0 but
                `cirq.rx(t)` uses a `global_shift` of -0.5, which is why
                `cirq.unitary(cirq.rx(pi))` equals -iX instead of X.

        Raises:
            TypeError: If the supplied exponent is a string.
            ValueError: If the supplied exponent is a complex number with an
                imaginary component.
        """
        if not isinstance(exponent, (numbers.Number, sympy.Expr)):
            raise TypeError(
                "Gate exponent must be a number or sympy expression. "
                f"Invalid type: {type(exponent).__name__!r}"
            )
        if isinstance(exponent, complex):
            if exponent.imag:
                raise ValueError(f"Gate exponent must be real. Invalid Value: {exponent}")
            exponent = exponent.real
        self._exponent = exponent
        self._global_shift = global_shift
Initializes the parameters used to compute the gate's matrix.

        Args:
            exponent: The t in gate**t. Determines how much the eigenvalues of
                the gate are phased by. For example, eigenvectors phased by -1
                when `gate**1` is applied will gain a relative phase of
                e^{i pi exponent} when `gate**exponent` is applied (relative to
                eigenvectors unaffected by `gate**1`).
            global_shift: Offsets the eigenvalues of the gate at exponent=1.
                In effect, this controls a global phase factor on the gate's
                unitary matrix. The factor is:

                    exp(i * pi * global_shift * exponent)

                For example, `cirq.X**t` uses a `global_shift` of 0 but
                `cirq.rx(t)` uses a `global_shift` of -0.5, which is why
                `cirq.unitary(cirq.rx(pi))` equals -iX instead of X.

        Raises:
            TypeError: If the supplied exponent is a string.
            ValueError: If the supplied exponent is a complex number with an
                imaginary component.
        
cirq-core/cirq/ops/eigen_gate.py