def _is_measurement_from_magic_method(val: Any) -> bool | None:
    """Uses `is_measurement` magic method to determine if this object is a measurement."""
    getter = getattr(val, '_is_measurement_', None)
    return NotImplemented if getter is None else getter()
Uses `is_measurement` magic method to determine if this object is a measurement.
cirq-core/cirq/protocols/measurement_key_protocol.py