code: def _get_components(x_in, adjacency, return_list=True):
      """Get connected components from a mask and a adjacency matrix."""
      if adjacency is False:
          components = np.arange(len(x_in))
      else:
          mask = np.logical_and(
              x_in[adjacency.row], x_in[adjacency.col]
          )
          data = adjacency.data[mask]
          row = adjacency.row[mask]
          col = adjacency.col[mask]
          shape = adjacency.shape
          idx = np.where(x_in)[0]
          row = np.concatenate((row, idx))
          col = np.concatenate((col, idx))
          data = np.concatenate(
              (data, np.ones(len(idx), dtype=data.dtype))
          )
          adjacency = sparse.coo_matrix((data, (row, col)), shape=shape)
          _, components = connected_components(adjacency)
      if return_list:
          start = np.min(components)
          stop = np.max(components)
          comp_list = [list() for i in range(start, stop + 1, 1)]
          mask = np.zeros(len(comp_list), dtype=bool)
          for ii, comp in enumerate(components):
              comp_list[comp].append(ii)
              mask[comp] += x_in[ii]
          clusters = [np.array(k) for k, m in zip(comp_list, mask) if m]
          return clusters
      else:
          return components
  
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 12 for calling a global function with example usage: _get_components(x_in, adjacency, return_list) and returns: clusters, components