code: def _make_data(rng=None, masked=False, dim=(2, 2, 2)):
      if rng is None:
          rng = np.random.default_rng(42)
      mask = np.ones(dim).astype(bool)
      mask[rng.random(dim) < 0.7] = 0
      w = np.zeros(dim)
      w[dim[0] // 2 :, dim[1] // 2 :, : dim[2] // 2] = 1
      n = 5
      X = np.ones([n] + list(dim))
      X += rng.standard_normal(X.shape)
      y = np.dot([x[mask] for x in X], w[mask])
      if masked:
          X = np.array([x[mask] for x in X])
          w = w[mask]
      else:
          X = np.rollaxis(X, 0, start=4)
          assert X.shape[-1] == n
      return X, y, w, mask
  
imports: import numpy
  import pytest
  from nibabel import Nifti1Image
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from sklearn.datasets import load_iris
  from nilearn.decoding._objective_functions import logistic_loss_lipschitz_constant, spectral_norm_squared, squared_loss, squared_loss_grad
  from nilearn.decoding.space_net import BaseSpaceNet, SpaceNetClassifier, SpaceNetRegressor
  from nilearn.decoding.space_net_solvers import _logistic_derivative_lipschitz_constant, _squared_loss_and_spatial_grad, _squared_loss_and_spatial_grad_derivative, _squared_loss_derivative_lipschitz_constant, graph_net_logistic, graph_net_squared_loss, tvl1_solver
  from nilearn.image import get_data
  from nilearn.masking import unmask_from_to_3d_array
label_desc: Use image node_id 1 for calling a global function with example usage: _make_data(rng, masked, dim) and returns: X,  y,  w,  mask