def from_measurement(
        cls, gate: ops.MeasurementGate, qubits: Sequence[cirq.Qid]
    ) -> TensoredConfusionMatrices:
        """Generates TCM for the confusion map in a MeasurementGate.

        This ignores any invert_mask defined for the gate - it only replicates the confusion map.

        Args:
            gate: the MeasurementGate to match.
            qubits: qubits the gate is applied to.

        Returns:
            TensoredConfusionMatrices matching the confusion map of the given gate.

        Raises:
            ValueError: if the gate has no confusion map.
        """
        if not gate.confusion_map:
            raise ValueError(f"Measurement has no confusion matrices: {gate}")
        confusion_matrices = []
        ordered_qubits = []
        for indices, cm in gate.confusion_map.items():
            confusion_matrices.append(cm)
            ordered_qubits.append(tuple(qubits[idx] for idx in indices))
        # Use zero for reps/timestamp to mark fake data.
        return cls(confusion_matrices, ordered_qubits, repetitions=0, timestamp=0)
Generates TCM for the confusion map in a MeasurementGate.

        This ignores any invert_mask defined for the gate - it only replicates the confusion map.

        Args:
            gate: the MeasurementGate to match.
            qubits: qubits the gate is applied to.

        Returns:
            TensoredConfusionMatrices matching the confusion map of the given gate.

        Raises:
            ValueError: if the gate has no confusion map.
        
cirq-core/cirq/experiments/readout_confusion_matrix.py