code: def _do_1samp_permutations(
      X,
      slices,
      threshold,
      tail,
      adjacency,
      stat_fun,
      max_step,
      include,
      partitions,
      t_power,
      orders,
      sample_shape,
      buffer_size,
      progress_bar,
  ):
      n_samp, n_vars = X.shape
      assert slices is None  # should be None for the 1 sample case
  
      if buffer_size is not None and n_vars <= buffer_size:
          buffer_size = None  # don't use buffer for few variables
  
      # allocate space for output
      max_cluster_sums = np.empty(len(orders), dtype=np.double)
  
      if buffer_size is not None:
          # allocate a buffer so we don't need to allocate memory in loop
          X_flip_buffer = np.empty((n_samp, buffer_size), dtype=X.dtype)
  
      for seed_idx, order in enumerate(orders):
          assert isinstance(order, np.ndarray)
          # new surrogate data with specified sign flip
          assert order.size == n_samp  # should be guaranteed by parent
          signs = 2 * order[:, None].astype(int) - 1
          if not np.all(np.equal(np.abs(signs), 1)):
              raise ValueError("signs from rng must be +/- 1")
  
          if buffer_size is None:
              # be careful about non-writable memmap (GH#1507)
              if X.flags.writeable:
                  X *= signs
                  # Recompute statistic on randomized data
                  t_obs_surr = stat_fun(X)
                  # Set X back to previous state (trade memory eff. for CPU use)
                  X *= signs
              else:
                  t_obs_surr = stat_fun(X * signs)
          else:
              # only sign-flip a small data buffer, so we need less memory
              t_obs_surr = np.empty(n_vars, dtype=X.dtype)
  
              for pos in range(0, n_vars, buffer_size):
                  # number of variables for this loop
                  n_var_loop = min(pos + buffer_size, n_vars) - pos
  
                  X_flip_buffer[:, :n_var_loop] = (
                      signs * X[:, pos : pos + n_var_loop]
                  )
  
                  # apply stat_fun and store result
                  tmp = stat_fun(X_flip_buffer)
                  t_obs_surr[pos : pos + n_var_loop] = tmp[:n_var_loop]
  
          # The stat should have the same shape as the samples for no adj.
          if adjacency is None:
              t_obs_surr.shape = sample_shape
  
          # Find cluster on randomized stats
          out = _find_clusters(
              t_obs_surr,
              threshold=threshold,
              tail=tail,
              max_step=max_step,
              adjacency=adjacency,
              partitions=partitions,
              include=include,
              t_power=t_power,
          )
          perm_clusters_sums = out[1]
          if len(perm_clusters_sums) > 0:
              # get max with sign info
              idx_max = np.argmax(np.abs(perm_clusters_sums))
              max_cluster_sums[seed_idx] = perm_clusters_sums[idx_max]
          else:
              max_cluster_sums[seed_idx] = 0
  
          progress_bar.update(seed_idx + 1)
  
      return max_cluster_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 21 for calling a global function with example usage: _do_1samp_permutations(X, slices, threshold, tail, adjacency, stat_fun, max_step, include, partitions, t_power, orders, sample_shape, buffer_size, progress_bar) and returns: max_cluster_sums