def __init__(
        self, p: float | Mapping[tuple[ops.Qid, ops.Qid], float], target_gate: ops.Gate = ops.CZ
    ):
        """Initialize the depolarizing noise transformer with some depolarizing probability and
        target gate.

        Args:
            p: The depolarizing probability, either a single float or a mapping from pairs of qubits
               to floats.
           target_gate: The gate after which to add depolarizing noise.

        Raises:
            TypeError: If `p` is not either be a float or a mapping from sorted qubit pairs to
                       floats.
        """

        if not isinstance(p, (Mapping, float)):
            raise TypeError(  # pragma: no cover
                "p must either be a float or a mapping from"  # pragma: no cover
                + "sorted qubit pairs to floats"  # pragma: no cover
            )  # pragma: no cover
        self.p = p
        self.p_func = (
            (lambda _: p)
            if isinstance(p, (int, float))
            else (lambda pair: cast(Mapping, p).get(pair, 0.0))
        )
        self.target_gate = target_gate
Initialize the depolarizing noise transformer with some depolarizing probability and
        target gate.

        Args:
            p: The depolarizing probability, either a single float or a mapping from pairs of qubits
               to floats.
           target_gate: The gate after which to add depolarizing noise.

        Raises:
            TypeError: If `p` is not either be a float or a mapping from sorted qubit pairs to
                       floats.
        
cirq-core/cirq/transformers/noise_adding.py