code: def test_adjacency_equiv(shape):
      """Test adjacency equivalence for lattice adjacency."""
      from sklearn.feature_extraction import grid_to_graph
  
      # sklearn requires at least two dimensions
      sk_shape = shape if len(shape) > 1 else (shape + (1,))
      conn_sk = grid_to_graph(*sk_shape).toarray()
      conn = combine_adjacency(*shape)
      want_shape = (np.prod(shape),) * 2
      assert conn.shape == conn_sk.shape == want_shape
      assert (conn.data == 1.0).all()
      conn = conn.toarray()
      # we end up with some duplicates that can turn into 2's and 3's,
      # eventually we might want to keep these as 1's but it's easy enough
      # with a .astype(bool) (also matches sklearn output) so let's leave it
      # for now
      assert np.isin(conn, [0, 1, 2, 3]).all()
      assert conn.shape == conn_sk.shape
      assert_array_equal(conn, conn_sk)
  
imports: import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from mne.stats import combine_adjacency
label_desc: Use image node_id 1 for calling a global function with example usage: test_adjacency_equiv(shape) without return types