code: def test_same_energy_calculus_pure_lasso(rng):
      X, y, w, mask = _make_data(rng=rng, masked=True)
  
      # check funcvals
      f1 = squared_loss(X, y, w)
      f2 = _squared_loss_and_spatial_grad(X, y, w.ravel(), mask, 0.0)
  
      assert f1 == f2
  
      # check derivatives
      g1 = squared_loss_grad(X, y, w)
      g2 = _squared_loss_and_spatial_grad_derivative(
          X, y, w.ravel(), mask, 0.0
      )
  
      assert_array_equal(g1, g2)
  
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 3 for calling a global function with example usage: test_same_energy_calculus_pure_lasso(rng) without return types