code: def test_tvl1_from_gradient(
      rng, alpha, l1_ratio, size=5, n_samples=10
  ):
      shape = [size] * 3
      n_voxels = np.prod(shape)
      X = rng.standard_normal((n_samples, n_voxels))
      y = rng.standard_normal(n_samples)
      w = rng.standard_normal(shape)
      mask = np.ones_like(w).astype(bool)
  
      gradid = gradient_id(w, l1_ratio=l1_ratio)
  
      assert _tvl1_objective(
          X, y, w.copy().ravel(), alpha, l1_ratio, mask
      ) == squared_loss(
          X, y, w.copy().ravel(), compute_grad=False
      ) + alpha * _tvl1_objective_from_gradient(
          gradid
      )
  
imports: import numpy
  import pytest
  from nilearn.decoding._objective_functions import gradient_id, squared_loss
  from nilearn.decoding.space_net_solvers import _tvl1_objective, _tvl1_objective_from_gradient, tvl1_solver
label_desc: Use image node_id 1 for calling a global function with example usage: test_tvl1_from_gradient(rng, alpha, l1_ratio, size, n_samples) without return types