def with_key(self, key: str | cirq.MeasurementKey) -> PauliMeasurementGate:
        """Creates a pauli measurement gate with a new key but otherwise identical."""
        if key == self.key:
            return self
        return PauliMeasurementGate(self._observable, key=key)
Creates a pauli measurement gate with a new key but otherwise identical.
cirq-core/cirq/ops/pauli_measurement_gate.py