code: def test_3d_images():
      # Test that the MultiNiftiMasker works with 3D images
      mask_img = Nifti1Image(
          np.ones((2, 2, 2), dtype=np.int8),
          affine=np.diag((4, 4, 4, 1)),
      )
      epi_img1 = Nifti1Image(
          np.ones((2, 2, 2)), affine=np.diag((4, 4, 4, 1))
      )
      epi_img2 = Nifti1Image(
          np.ones((2, 2, 2)), affine=np.diag((2, 2, 2, 1))
      )
      masker = MultiNiftiMasker(mask_img=mask_img)
  
      # Check attributes defined at fit
      assert not hasattr(masker, "mask_img_")
      assert not hasattr(masker, "n_elements_")
  
      epis = masker.fit_transform([epi_img1, epi_img2])
  
      # This is mostly a smoke test
      assert len(epis) == 2
  
      # Check attributes defined at fit
      assert hasattr(masker, "mask_img_")
      assert hasattr(masker, "n_elements_")
  
      # verify that 4D mask arguments are refused
      mask_img_4d = Nifti1Image(
          np.ones((2, 2, 2, 2), dtype=np.int8),
          affine=np.diag((4, 4, 4, 1)),
      )
      masker2 = MultiNiftiMasker(mask_img=mask_img_4d)
      with pytest.raises(
          DimensionError,
          match="Input data has incompatible dimensionality: "
          "Expected dimension is 3D and you provided "
          "a 4D image.",
      ):
          masker2.fit()
  
imports: import shutil
  from tempfile import mkdtemp
  import numpy
  import pytest
  from joblib import Memory
  from nibabel import Nifti1Image
  from numpy.testing import assert_array_equal
  from nilearn._utils.exceptions import DimensionError
  from nilearn._utils.testing import write_imgs_to_path
  from nilearn.conftest import _rng
  from nilearn.image import get_data
  from nilearn.maskers import MultiNiftiMasker
label_desc: Use image node_id 4 for calling a global function with example usage: test_3d_images() without return types