def __call__(
        self,
        circuit: cirq.AbstractCircuit,
        unitary_ensemble: str = "pauli",
        rng: np.random.Generator | None = None,
        *,
        context: transformer_api.TransformerContext | None = None,
    ) -> cirq.Circuit:
        """Apply the transformer to the given circuit. Given an input circuit returns
        a new circuit with the pre-measurement unitaries and measurements gates added.
        to the qubits in the subsystem provided.If no subsystem is specified in the
        construction of this class it defaults to measuring all the qubits in the
        randomized bases.

        Args:
            circuit: The circuit to add randomized measurements to.
            unitary_ensemble: Choice of unitary ensemble (pauli/clifford/cue(circular
                unitary ensemble))
            context: Not used; to satisfy transformer API.
            rng: Random number generator.

        Returns:
            A circuit with pre-measurement unitaries and measurements added
        """

        all_qubits = sorted(circuit.all_qubits())
        if self.subsystem is None:
            subsystem_qubits = all_qubits
        else:
            subsystem_qubits = [all_qubits[s] for s in self.subsystem]
        if rng is None:
            rng = np.random.default_rng()

        pre_measurement_moment = self.random_single_qubit_unitary_moment(
            unitary_ensemble, subsystem_qubits, rng
        )

        return cirq.Circuit.from_moments(
            *circuit.moments, pre_measurement_moment, cirq.M(*subsystem_qubits, key="m")
        )
Apply the transformer to the given circuit. Given an input circuit returns
        a new circuit with the pre-measurement unitaries and measurements gates added.
        to the qubits in the subsystem provided.If no subsystem is specified in the
        construction of this class it defaults to measuring all the qubits in the
        randomized bases.

        Args:
            circuit: The circuit to add randomized measurements to.
            unitary_ensemble: Choice of unitary ensemble (pauli/clifford/cue(circular
                unitary ensemble))
            context: Not used; to satisfy transformer API.
            rng: Random number generator.

        Returns:
            A circuit with pre-measurement unitaries and measurements added
        
cirq-core/cirq/transformers/randomized_measurements.py