code: def test_squared_loss_gradient_at_simple_points():
      """Test gradient of data loss function in points near to zero.
  
      This is a not so hard test, just for detecting big errors.
      """
      X, y, w, mask = create_graph_net_simulation_data(
          n_samples=10, size=4
      )
      grad_weight = 1
  
      def func(w):
          return _squared_loss_and_spatial_grad(
              X, y, w, mask, grad_weight
          )
  
      def func_grad(w):
          return _squared_loss_and_spatial_grad_derivative(
              X, y, w, mask, grad_weight
          )
  
      for i in range(0, w.size, 2):
          point = np.zeros(*w.shape)
          point[i] = 1
  
          assert_almost_equal(
              sp.optimize.check_grad(func, func_grad, point),
              0,
              decimal=3,
          )
  
imports: import numpy
  import pytest
  import scipy
  from nibabel import Nifti1Image
  from numpy.testing import assert_almost_equal
  from scipy import linalg
  from nilearn.decoding._objective_functions import divergence, gradient
  from nilearn.decoding.space_net import BaseSpaceNet
  from nilearn.decoding.space_net_solvers import _graph_net_adjoint_data_function, _graph_net_data_function, _logistic_data_loss_and_spatial_grad, _logistic_data_loss_and_spatial_grad_derivative, _logistic_derivative_lipschitz_constant, _squared_loss_and_spatial_grad, _squared_loss_and_spatial_grad_derivative, _squared_loss_derivative_lipschitz_constant, mfista
  from nilearn.decoding.tests._testing import create_graph_net_simulation_data
  from .test_same_api import to_niimgs
label_desc: Use image node_id 7 for calling a global function with example usage: test_squared_loss_gradient_at_simple_points() and returns: _squared_loss_and_spatial_grad, _squared_loss_and_spatial_grad_derivative