code: def _crop_mask(mask):
      """Crops input mask to produce tighter (i.e smaller) bounding box \
      with the same support (active voxels)."""
      idx = np.where(mask)
      if idx[0].size == 0:
          raise ValueError(
              "Empty mask: if you have given a mask, it is "
              "empty, and if you have not given a mask, the "
              "mask-extraction routines have failed. Please "
              "provide an appropriate mask."
          )
      i_min = max(idx[0].min() - 1, 0)
      i_max = idx[0].max()
      j_min = max(idx[1].min() - 1, 0)
      j_max = idx[1].max()
      k_min = max(idx[2].min() - 1, 0)
      k_max = idx[2].max()
      return mask[
          i_min : i_max + 1, j_min : j_max + 1, k_min : k_max + 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 1 for calling a global function with example usage: _crop_mask(mask) and returns: mask