code: def test_anisotropic_sphere_extraction(rng):
      data = rng.random((3, 3, 3, 5))
      affine = np.eye(4)
      affine[0, 0] = 2
      affine[2, 2] = 2
      img = nibabel.Nifti1Image(data, affine)
      masker = NiftiSpheresMasker([(2, 1, 2)], radius=1)
      # Test the fit
      masker.fit()
      # Test the transform
      s = masker.transform(img)
      mask = np.zeros((3, 3, 3), dtype=bool)
      mask[1, :, 1] = True
      assert_array_equal(s[:, 0], np.mean(data[mask], axis=0))
      # Now with a mask
      mask_img = np.zeros((3, 2, 3))
      mask_img[1, 0, 1] = 1
      affine_2 = affine.copy()
      affine_2[0, 0] = 4
      mask_img = nibabel.Nifti1Image(mask_img, affine=affine_2)
      masker = NiftiSpheresMasker(
          [(2, 1, 2)], radius=1, mask_img=mask_img
      )
  
      masker.fit()
      s = masker.transform(img)
      assert_array_equal(s[:, 0], data[1, 0, 1])
  
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 3 for calling a global function with example usage: test_anisotropic_sphere_extraction(rng) without return types