def __call__(
        self,
        circuit: circuits.AbstractCircuit,
        rng: np.random.Generator | None = None,
        *,
        context: transformer_api.TransformerContext | None = None,
    ):
        """Apply the transformer to the given circuit.

        Args:
            circuit: The circuit to add noise to.
            context: Not used; to satisfy transformer API.

        Returns:
            The transformed circuit.
        """
        if rng is None:
            rng = np.random.default_rng()
        target_gate = self.target_gate

        # add random Pauli gates with probability p after each of the specified gate
        assert target_gate.num_qubits() == 2, "`target_gate` must be a two-qubit gate."
        paulis = [ops.I, ops.X, ops.Y, ops.Z]
        new_moments = []
        for moment in circuit:
            new_moments.append(moment)
            if _gate_in_moment(target_gate, moment):
                # add a new moment with the Paulis
                target_pairs = {
                    tuple(sorted(op.qubits)) for op in moment.operations if op.gate == target_gate
                }
                added_moment_ops = []
                for pair in target_pairs:
                    pair_sorted_tuple = (pair[0], pair[1])
                    p_i = self.p_func(pair_sorted_tuple)
                    apply = rng.choice([True, False], p=[p_i, 1 - p_i])
                    if apply:
                        choices = [
                            (pauli_a(pair[0]), pauli_b(pair[1]))
                            for pauli_a in paulis
                            for pauli_b in paulis
                        ][1:]
                        pauli_to_apply = rng.choice(np.array(choices, dtype=object))
                        added_moment_ops.append(pauli_to_apply)
                if len(added_moment_ops) > 0:
                    new_moments.append(circuits.Moment(*added_moment_ops))
        return circuits.Circuit.from_moments(*new_moments)
Apply the transformer to the given circuit.

        Args:
            circuit: The circuit to add noise to.
            context: Not used; to satisfy transformer API.

        Returns:
            The transformed circuit.
        
cirq-core/cirq/transformers/noise_adding.py