code: def test_grad_div_adjoint_arbitrary_ndim(rng, ndim, l1_ratio, size):
      # We need to check that <D x, y> = <x, DT y> for x and y random vectors
      shape = tuple([size] * ndim)
      x = rng.normal(size=shape)
      y = rng.normal(size=[ndim + 1] + list(shape))
  
      assert_almost_equal(
          np.sum(gradient_id(x, l1_ratio=l1_ratio) * y),
          -np.sum(x * divergence_id(y, l1_ratio=l1_ratio)),
      )
  
file_path: nilearn/nilearn/decoding/tests/test_objective_functions.py
imports: import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_equal
  from scipy.optimize import check_grad
  from nilearn.decoding._objective_functions import divergence_id, gradient_id, logistic_loss, logistic_loss_grad
  from nilearn.decoding.space_net import BaseSpaceNet
label_desc: Use image node_id 1 for calling a global function with example usage: test_grad_div_adjoint_arbitrary_ndim(rng, ndim, l1_ratio, size) without return types