code: def _check_param_grid(estimator, X, y, param_grid=None):
      """Check param_grid and return sensible default if param_grid is None.
  
      Parameters
      ----------
      estimator: str
          The estimator to choose among:
          %(classifier_options)s
          %(regressor_options)s
  
      X: list of Niimg-like objects
          See :ref:`extracting_data`.
          Data on which model is to be fitted. If this is a list,
          the affine is considered the same for all.
  
      y: array or list of shape (n_samples)
          The dependent variable (age, sex, IQ, yes/no, etc.).
          Target variable to predict. Must have exactly as many elements as
          3D images in niimg.
  
      param_grid: dict of str to sequence, or sequence of such. Default None
          The parameter grid to explore, as a dictionary mapping estimator
          parameters to sequences of allowed values.
  
          An empty dict signifies default parameters.
  
          A sequence of dicts signifies a sequence of grids to search, and is
          useful to avoid exploring parameter combinations that make no sense
          or have no effect. See scikit-learn documentation for more information.
  
          For Dummy estimators, parameter grid defaults to empty as these
          estimators do not have hyperparameters to grid search.
  
      Returns
      -------
      param_grid: dict of str to sequence, or sequence of such. Sensible default
      dict has size 1 for linear models.
  
      """
      if param_grid is None:
          param_grid = _default_param_grid(estimator, X, y)
  
      else:
          if isinstance(estimator, (RidgeCV, RidgeClassifierCV)):
              param_grid = _wrap_param_grid(param_grid, "alphas")
          elif isinstance(estimator, LogisticRegressionCV):
              param_grid = _replace_param_grid_key(
                  param_grid, "C", "Cs"
              )
              param_grid = _wrap_param_grid(param_grid, "Cs")
          elif isinstance(estimator, LassoCV):
              param_grid = _wrap_param_grid(param_grid, "alphas")
  
      return param_grid
  
imports: import itertools
  import warnings
  from typing import Iterable
  import numpy
  from joblib import Parallel, delayed
  from sklearn import clone
  from sklearn.base import BaseEstimator, MultiOutputMixin
  from sklearn.dummy import DummyClassifier, DummyRegressor
  from sklearn.linear_model import LassoCV, LogisticRegressionCV, RidgeClassifierCV, RidgeCV
  from sklearn.metrics import check_scoring, get_scorer
  from sklearn.model_selection import LeaveOneGroupOut, ParameterGrid, ShuffleSplit, StratifiedShuffleSplit, check_cv
  from sklearn.preprocessing import LabelBinarizer
  from sklearn.svm import SVR, LinearSVC, l1_min_c
  from sklearn.utils.extmath import safe_sparse_dot
  from sklearn.utils.validation import check_is_fitted, check_X_y
  from nilearn._utils import CacheMixin, fill_doc
  from nilearn._utils.cache_mixin import _check_memory
  from nilearn._utils.masker_validation import check_embedded_masker
  from nilearn._utils.param_validation import check_feature_screening
  from nilearn.experimental.surface import SurfaceMasker
  from nilearn.regions.rena_clustering import ReNA
label_desc: Use image node_id 1 for calling a global function with example usage: _check_param_grid(estimator, X, y, param_grid) and returns: param_grid