code: def _get_partitions_from_adjacency(adjacency, n_times, verbose=None):
      """Specify disjoint subsets (e.g., hemispheres) based on adjacency."""
      if isinstance(adjacency, list):
          test = np.ones(len(adjacency))
          test_adj = np.zeros(
              (len(adjacency), len(adjacency)), dtype="bool"
          )
          for vi in range(len(adjacency)):
              test_adj[adjacency[vi], vi] = True
          test_adj = sparse.coo_matrix(test_adj, dtype="float")
      else:
          test = np.ones(adjacency.shape[0])
          test_adj = adjacency
  
      part_clusts = _find_clusters(test, 0, 1, test_adj)[0]
      if len(part_clusts) > 1:
          logger.info(
              "%i disjoint adjacency sets found" % len(part_clusts)
          )
          partitions = np.zeros(len(test), dtype="int")
          for ii, pc in enumerate(part_clusts):
              partitions[pc] = ii
          if isinstance(adjacency, list):
              partitions = np.tile(partitions, n_times)
      else:
          logger.info("No disjoint adjacency sets found")
          partitions = None
  
      return partitions
  
imports: import numpy
  from scipy import ndimage, sparse
  from scipy.sparse.csgraph import connected_components
  from scipy.stats import f
  from scipy.stats import t
  from ..fixes import has_numba, jit
  from ..parallel import parallel_func
  from ..source_estimate import MixedSourceEstimate, SourceEstimate, VolSourceEstimate
  from ..source_space import SourceSpaces
  from ..utils import ProgressBar, _check_option, _pl, _validate_type, check_random_state, logger, split_list, verbose, warn
  from .parametric import f_oneway, ttest_1samp_no_p
label_desc: Use image node_id 31 for calling a global function with example usage: _get_partitions_from_adjacency(adjacency, n_times, verbose) and returns: partitions