def _strat_commutes_from_matrix(
    v1: Any, v2: Any, *, atol: float
) -> bool | NotImplementedType | None:
    """Attempts to determine commutativity of matrices."""
    if not isinstance(v1, np.ndarray) or not isinstance(v2, np.ndarray):
        return NotImplemented
    if v1.shape != v2.shape:
        return None
    return linalg.matrix_commutes(v1, v2, atol=atol)
Attempts to determine commutativity of matrices.
cirq-core/cirq/protocols/commutes_protocol.py