code: def _space_net_alpha_grid(
      X, y, eps=1e-3, n_alphas=10, l1_ratio=1.0, logistic=False
  ):
      """Compute the grid of alpha values for TV-L1 and Graph-Net.
  
      Parameters
      ----------
      X : ndarray, shape (n_samples, n_features)
          Training data (design matrix).
  
      y : ndarray, shape (n_samples,)
          Target / response vector.
  
      l1_ratio : float, default=1
          The ElasticNet mixing parameter, with ``0 <= l1_ratio <= 1``.
          For ``l1_ratio = 0`` the penalty is purely a spatial prior
          (Graph-Net, TV, etc.). ``For l1_ratio = 1`` it is an L1 penalty.
          For ``0 < l1_ratio < 1``, the penalty is a combination of L1
          and a spatial prior.
  
      eps : float, default=1e-3
          Length of the path. ``eps=1e-3`` means that
          ``alpha_min / alpha_max = 1e-3``.
  
      n_alphas : int, default=10
          Number of alphas along the regularization path.
  
      logistic : bool, default=False
          Indicates where the underlying loss function is logistic.
  
      """
      if logistic:
          # Computes the theoretical upper bound for the overall
          # regularization, as derived in "An Interior-Point Method for
          # Large-Scale l1-Regularized Logistic Regression", by Koh, Kim,
          # Boyd, in Journal of Machine Learning Research, 8:1519-1555,
          # July 2007.
          # url: https://web.stanford.edu/~boyd/papers/pdf/l1_logistic_reg.pdf
          m = float(y.size)
          m_plus = float(y[y == 1].size)
          m_minus = float(y[y == -1].size)
          b = np.zeros_like(y)
          b[y == 1] = m_minus / m
          b[y == -1] = -m_plus / m
          alpha_max = np.max(np.abs(X.T.dot(b)))
  
          # tt may happen that b is in the kernel of X.T!
          if alpha_max == 0.0:
              alpha_max = np.abs(np.dot(X.T, y)).max()
      else:
          alpha_max = np.abs(np.dot(X.T, y)).max()
  
      # prevent alpha_max from exploding when l1_ratio = 0
      if l1_ratio == 0.0:
          l1_ratio = 1e-3
      alpha_max /= l1_ratio
  
      if n_alphas == 1:
          return np.array([alpha_max])
  
      alpha_min = alpha_max * eps
      return np.logspace(
          np.log10(alpha_min), np.log10(alpha_max), num=n_alphas
      )[::-1]
  
imports: import collections
  import sys
  import time
  import warnings
  from functools import partial
  import numpy
  from joblib import Memory, Parallel, delayed
  from scipy import stats
  from scipy.ndimage import binary_dilation, binary_erosion, gaussian_filter
  from sklearn.feature_selection import SelectPercentile, f_classif, f_regression
  from sklearn.linear_model import LinearRegression
  from sklearn.linear_model._base import _preprocess_data
  from sklearn.metrics import accuracy_score
  from sklearn.model_selection import check_cv
  from sklearn.preprocessing import LabelBinarizer
  from sklearn.utils import check_array, check_X_y
  from sklearn.utils.extmath import safe_sparse_dot
  from nilearn._utils.masker_validation import check_embedded_masker
  from nilearn.experimental.surface import SurfaceMasker
  from nilearn.image import get_data
  from nilearn.masking import unmask_from_to_3d_array
  from .._utils import fill_doc
  from .._utils.cache_mixin import CacheMixin
  from .._utils.param_validation import adjust_screening_percentile
  from .space_net_solvers import graph_net_logistic, graph_net_squared_loss, tvl1_solver
label_desc: Use image node_id 3 for calling a global function with example usage: _space_net_alpha_grid(X, y, eps, n_alphas, l1_ratio, logistic) and returns: np, np