code: def test_permutation_adjacency_equiv(numba_conditional):
      """Test cluster level permutations with and without adjacency."""
      pytest.importorskip("sklearn")
      from sklearn.feature_extraction.image import grid_to_graph
  
      rng = np.random.RandomState(0)
      # subjects, time points, spatial points
      n_time = 2
      n_space = 4
      X = rng.randn(6, n_time, n_space)
      # add some significant points
      X[:, :, 0:2] += 10  # span two time points and two spatial points
      X[:, 1, 3] += 20  # span one time point
      max_steps = [1, 1, 1, 2, 1]
      # This will run full algorithm in two ways, then the ST-algorithm in 2 ways
      # All of these should give the same results
      adjs = [
          None,
          grid_to_graph(n_time, n_space),
          grid_to_graph(1, n_space),
          grid_to_graph(1, n_space),
          None,
      ]
      stat_map = None
      thresholds = [2, 2, 2, 2, dict(start=0.01, step=1.0)]
      sig_counts = [2, 2, 2, 2, 5]
      stat_fun = partial(ttest_1samp_no_p, sigma=1e-3)
  
      cs = None
      ps = None
      for thresh, count, max_step, adj in zip(
          thresholds, sig_counts, max_steps, adjs
      ):
          t, clusters, p, H0 = permutation_cluster_1samp_test(
              X,
              threshold=thresh,
              adjacency=adj,
              n_jobs=2,
              max_step=max_step,
              stat_fun=stat_fun,
              seed=0,
              out_type="mask",
          )
          # make sure our output datatype is correct
          assert isinstance(clusters[0], np.ndarray)
          assert clusters[0].dtype == np.dtype(bool)
          assert_array_equal(clusters[0].shape, X.shape[1:])
  
          # make sure all comparisons were done; for TFCE, no perm
          # should come up empty
          inds = np.where(p < 0.05)[0]
          assert_equal(len(inds), count)
          assert_allclose(p[inds], 0.03125, atol=1e-6)
          if isinstance(thresh, dict):
              assert_equal(len(clusters), n_time * n_space)
              assert np.all(H0 != 0)
              continue
          this_cs = [clusters[ii] for ii in inds]
          this_ps = p[inds]
          this_stat_map = np.zeros((n_time, n_space), dtype=bool)
          for ci, c in enumerate(this_cs):
              if isinstance(c, tuple):
                  this_c = np.zeros((n_time, n_space), bool)
                  for x, y in zip(c[0], c[1]):
                      this_stat_map[x, y] = True
                      this_c[x, y] = True
                  this_cs[ci] = this_c
                  c = this_c
              this_stat_map[c] = True
          if cs is None:
              ps = this_ps
              cs = this_cs
          if stat_map is None:
              stat_map = this_stat_map
          assert_array_equal(ps, this_ps)
          assert len(cs) == len(this_cs)
          for c1, c2 in zip(cs, this_cs):
              assert_array_equal(c1, c2)
          assert_array_equal(stat_map, this_stat_map)
  
imports: import os
  from functools import partial
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy import linalg, sparse, stats
  from mne import MixedSourceEstimate, SourceEstimate, SourceSpaces, VolSourceEstimate
  from mne.stats import combine_adjacency, ttest_ind_no_p
  from mne.stats.cluster_level import f_oneway, permutation_cluster_1samp_test, permutation_cluster_test, spatio_temporal_cluster_1samp_test, spatio_temporal_cluster_test, summarize_clusters_stc, ttest_1samp_no_p
  from mne.utils import _record_warnings, catch_logging
label_desc: Use image node_id 10 for calling a global function with example usage: test_permutation_adjacency_equiv(numba_conditional) without return types