def _strat_unitary_from_unitary(val: Any) -> np.ndarray | None:
    """Attempts to compute a value's unitary via its _unitary_ method."""
    getter = getattr(val, '_unitary_', None)
    if getter is None:
        return NotImplemented
    return getter()
Attempts to compute a value's unitary via its _unitary_ method.
cirq-core/cirq/protocols/unitary_protocol.py