Return true if gate tensor is (almost) the identity

def almost_identity(gate: Gate) -> bool:
    """Return true if gate tensor is (almost) the identity"""
    N = gate.qubit_nb
    return np.allclose(asarray(gate.asoperator()), np.eye(2**N))