code: def _find_clusters(
      x,
      threshold,
      tail=0,
      adjacency=None,
      max_step=1,
      include=None,
      partitions=None,
      t_power=1,
      show_info=False,
  ):
      """Find all clusters which are above/below a certain threshold.
  
      When doing a two-tailed test (tail == 0), only points with the same
      sign will be clustered together.
  
      Parameters
      ----------
      x : 1D array
          Data
      threshold : float | dict
          Where to threshold the statistic. Should be negative for tail == -1,
          and positive for tail == 0 or 1. Can also be an dict for
          threshold-free cluster enhancement.
      tail : -1 | 0 | 1
          Type of comparison
      adjacency : scipy.sparse.coo_matrix, None, or list
          Defines adjacency between features. The matrix is assumed to
          be symmetric and only the upper triangular half is used.
          If adjacency is a list, it is assumed that each entry stores the
          indices of the spatial neighbors in a spatio-temporal dataset x.
          Default is None, i.e, a regular lattice adjacency.
          False means no adjacency.
      max_step : int
          If adjacency is a list, this defines the maximal number of steps
          between vertices along the second dimension (typically time) to be
          considered adjacent.
      include : 1D bool array or None
          Mask to apply to the data of points to cluster. If None, all points
          are used.
      partitions : array of int or None
          An array (same size as X) of integers indicating which points belong
          to each partition.
      t_power : float
          Power to raise the statistical values (usually t-values) by before
          summing (sign will be retained). Note that t_power == 0 will give a
          count of nodes in each cluster, t_power == 1 will weight each node by
          its statistical score.
      show_info : bool
          If True, display information about thresholds used (for TFCE). Should
          only be done for the standard permutation.
  
      Returns
      -------
      clusters : list of slices or list of arrays (boolean masks)
          We use slices for 1D signals and mask to multidimensional
          arrays.
      sums : array
          Sum of x values in clusters.
      """
      _check_option("tail", tail, [-1, 0, 1])
  
      x = np.asanyarray(x)
  
      if not np.isscalar(threshold):
          if not isinstance(threshold, dict):
              raise TypeError(
                  "threshold must be a number, or a dict for "
                  "threshold-free cluster enhancement"
              )
          if not all(key in threshold for key in ["start", "step"]):
              raise KeyError(
                  "threshold, if dict, must have at least "
                  '"start" and "step"'
              )
          tfce = True
          use_x = x[np.isfinite(x)]
          if use_x.size == 0:
              raise RuntimeError(
                  "No finite values found in the observed statistic values"
              )
          if tail == -1:
              if threshold["start"] > 0:
                  raise ValueError(
                      'threshold["start"] must be <= 0 for '
                      "tail == -1"
                  )
              if threshold["step"] >= 0:
                  raise ValueError(
                      'threshold["step"] must be < 0 for ' "tail == -1"
                  )
              stop = np.min(use_x)
          elif tail == 1:
              stop = np.max(use_x)
          else:  # tail == 0
              stop = max(np.max(use_x), -np.min(use_x))
          del use_x
          thresholds = np.arange(
              threshold["start"], stop, threshold["step"], float
          )
          h_power = threshold.get("h_power", 2)
          e_power = threshold.get("e_power", 0.5)
          if show_info is True:
              if len(thresholds) == 0:
                  warn(
                      'threshold["start"] (%s) is more extreme than data '
                      "statistics with most extreme value %s"
                      % (threshold["start"], stop)
                  )
              else:
                  logger.info(
                      "Using %d thresholds from %0.2f to %0.2f for TFCE "
                      "computation (h_power=%0.2f, e_power=%0.2f)"
                      % (
                          len(thresholds),
                          thresholds[0],
                          thresholds[-1],
                          h_power,
                          e_power,
                      )
                  )
          scores = np.zeros(x.size)
      else:
          thresholds = [threshold]
          tfce = False
  
      # include all points by default
      if include is None:
          include = np.ones(x.shape, dtype=bool)
  
      if tail in [0, 1] and not np.all(np.diff(thresholds) > 0):
          raise ValueError(
              "Thresholds must be monotonically increasing"
          )
      if tail == -1 and not np.all(np.diff(thresholds) < 0):
          raise ValueError(
              "Thresholds must be monotonically decreasing"
          )
  
      # set these here just in case thresholds == []
      clusters = list()
      sums = list()
      for ti, thresh in enumerate(thresholds):
          # these need to be reset on each run
          clusters = list()
          if tail == 0:
              x_ins = [
                  np.logical_and(x > thresh, include),
                  np.logical_and(x < -thresh, include),
              ]
          elif tail == -1:
              x_ins = [np.logical_and(x < thresh, include)]
          else:  # tail == 1
              x_ins = [np.logical_and(x > thresh, include)]
          # loop over tails
          for x_in in x_ins:
              if np.any(x_in):
                  out = _find_clusters_1dir_parts(
                      x,
                      x_in,
                      adjacency,
                      max_step,
                      partitions,
                      t_power,
                      ndimage,
                  )
                  clusters += out[0]
                  sums.append(out[1])
          if tfce:
              # the score of each point is the sum of the h^H * e^E for each
              # supporting section "rectangle" h x e.
              if ti == 0:
                  h = abs(thresh)
              else:
                  h = abs(thresh - thresholds[ti - 1])
              h = h**h_power
              for c in clusters:
                  # triage based on cluster storage type
                  if isinstance(c, slice):
                      len_c = c.stop - c.start
                  elif isinstance(c, tuple):
                      len_c = len(c)
                  elif c.dtype == np.dtype(bool):
                      len_c = np.sum(c)
                  else:
                      len_c = len(c)
                  scores[c] += h * (len_c**e_power)
      # turn sums into array
      sums = np.concatenate(sums) if sums else np.array([])
      if tfce:
          # each point gets treated independently
          clusters = np.arange(x.size)
          if adjacency is None or adjacency is False:
              if x.ndim == 1:
                  # slices
                  clusters = [slice(c, c + 1) for c in clusters]
              else:
                  # boolean masks (raveled)
                  clusters = [
                      (clusters == ii).ravel()
                      for ii in range(len(clusters))
                  ]
          else:
              clusters = [np.array([c]) for c in clusters]
          sums = scores
      return clusters, sums
  
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 13 for calling a global function with example usage: _find_clusters(x, threshold, tail, adjacency, max_step, include, partitions, t_power, show_info) and returns: clusters,  sums