code: def test_nifti_spheres_masker_inverse_transform(rng):
      # Applying the sphere_extraction example from above backwards
      data = rng.random((3, 3, 3, 5))
      img = nibabel.Nifti1Image(data, np.eye(4))
      masker = NiftiSpheresMasker([(1, 1, 1)], radius=1)
      # Test the fit
      masker.fit()
      # Transform data
      with pytest.raises(ValueError, match="Please provide mask_img"):
          masker.inverse_transform(data[0, 0, 0, :])
  
      # Mask describes the extend of the masker's sphere
      mask = np.zeros((3, 3, 3), dtype=bool)
      mask[:, 1, 1] = True
      mask[1, :, 1] = True
      mask[1, 1, :] = True
  
      # Now with a mask
      mask_img = np.zeros((3, 3, 3))
      mask_img[1, :, :] = 1
      mask_img = nibabel.Nifti1Image(mask_img, np.eye(4))
      masker = NiftiSpheresMasker(
          [(1, 1, 1)], radius=1, mask_img=mask_img
      )
      masker.fit()
      s = masker.transform(img)
      # Create an array mask
      array_mask = np.logical_and(mask, get_data(mask_img))
  
      inverse_map = masker.inverse_transform(s)
  
      # Testing whether mask is applied to inverse transform
      assert_array_equal(
          np.mean(get_data(inverse_map), axis=-1) != 0, array_mask
      )
      # Test whether values are preserved
      assert_array_equal(
          get_data(inverse_map)[array_mask].mean(0), s[:, 0]
      )
  
      # Test whether the mask's shape is applied
      assert_array_equal(inverse_map.shape[:3], mask_img.shape)
  
imports: import warnings
  import nibabel
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from nilearn._utils import data_gen
  from nilearn.image import get_data, new_img_like
  from nilearn.maskers import NiftiSpheresMasker
label_desc: Use image node_id 9 for calling a global function with example usage: test_nifti_spheres_masker_inverse_transform(rng) without return types