code: def test_adjointness(rng, size=4):
      """Test for adjointness between gradient and divergence operators."""
      for _ in range(3):
          image_1 = rng.random((size, size, size))
          image_2 = rng.random((3, size, size, size))
          Axdoty = np.dot((gradient(image_1).ravel()), image_2.ravel())
  
          xdotAty = np.dot(
              (divergence(image_2).ravel()), image_1.ravel()
          )
  
          assert_almost_equal(Axdoty, -xdotAty)
  
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 4 for calling a global function with example usage: test_adjointness(rng, size) without return types