code: def test_check_niimg_4d(
      affine_eye, img_3d_zeros_eye, shape_3d_default
  ):
      # Tests with return_iterator=False
      img_4d_1 = _utils.check_niimg_4d(
          [img_3d_zeros_eye, img_3d_zeros_eye]
      )
      assert get_data(img_4d_1).shape == (10, 10, 10, 2)
      assert_array_equal(img_4d_1.affine, affine_eye)
  
      img_4d_2 = _utils.check_niimg_4d(img_4d_1)
      assert_array_equal(get_data(img_4d_2), get_data(img_4d_2))
      assert_array_equal(img_4d_2.affine, img_4d_2.affine)
  
      # Tests with return_iterator=True
      img_3d_iterator = _utils.check_niimg_4d(
          [img_3d_zeros_eye, img_3d_zeros_eye], return_iterator=True
      )
      img_3d_iterator_length = sum(1 for _ in img_3d_iterator)
      assert img_3d_iterator_length == 2
  
      img_3d_iterator_1 = _utils.check_niimg_4d(
          [img_3d_zeros_eye, img_3d_zeros_eye], return_iterator=True
      )
      img_3d_iterator_2 = _utils.check_niimg_4d(
          img_3d_iterator_1, return_iterator=True
      )
      for img_1, img_2 in zip(img_3d_iterator_1, img_3d_iterator_2):
          assert get_data(img_1).shape == shape_3d_default
          assert_array_equal(get_data(img_1), get_data(img_2))
          assert_array_equal(img_1.affine, img_2.affine)
  
      img_3d_iterator_1 = _utils.check_niimg_4d(
          [img_3d_zeros_eye, img_3d_zeros_eye], return_iterator=True
      )
      img_3d_iterator_2 = _utils.check_niimg_4d(
          img_4d_1, return_iterator=True
      )
      for img_1, img_2 in zip(img_3d_iterator_1, img_3d_iterator_2):
          assert get_data(img_1).shape == shape_3d_default
          assert_array_equal(get_data(img_1), get_data(img_2))
          assert_array_equal(img_1.affine, img_2.affine)
  
      # Test a Niimg-like object that does not hold a shape attribute
      phony_img = PhonyNiimage()
      _utils.check_niimg_4d(phony_img)
  
imports: import os
  import re
  import tempfile
  from pathlib import Path
  import nibabel
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from numpy.testing import assert_array_equal
  import nilearn
  from nilearn import _utils
  from nilearn._utils import niimg_conversions, testing
  from nilearn._utils.exceptions import DimensionError
  from nilearn._utils.niimg_conversions import iter_check_niimg
  from nilearn._utils.testing import assert_memory_less_than, with_memory_profiler
  from nilearn.image import get_data
label_desc: Use image node_id 4 for calling a global function with example usage: test_check_niimg_4d(affine_eye, img_3d_zeros_eye, shape_3d_default) without return types