code: def _apply_func(x, g, func):
      # g is list of indices into x
      #  separating x into different groups
      #  func should be applied over the groups
      g = unique(r_[0, g, len(x)])
      output = [func(x[g[k] : g[k + 1]]) for k in range(len(g) - 1)]
  
      return asarray(output)
  
imports: from __future__ import annotations
  import math
  import warnings
  from collections import namedtuple
  import numpy
  from numpy import isscalar, r_, log, around, unique, asarray, zeros, arange, sort, amin, amax, atleast_1d, sqrt, array, compress, pi, exp, ravel, count_nonzero, sin, cos, arctan2, hypot
  from scipy import optimize
  from scipy import special
  from .None import statlib
  from .None import stats
  from .stats import find_repeats, _contains_nan, _normtest_finish
  from .contingency import chi2_contingency
  from .None import distributions
  from ._distn_infrastructure import rv_generic
  from ._hypotests import _get_wilcoxon_distr
label_desc: Use image node_id 31 for calling a global function with example usage: _apply_func(x, g, func) and returns: asarray