code: def test_check_niimg_3d(affine_eye, img_3d_zeros_eye, tmp_path):
      # check error for non-forced but necessary resampling
      with pytest.raises(TypeError, match="nibabel format"):
          _utils.check_niimg(0)
  
      # check error for non-forced but necessary resampling
      with pytest.raises(TypeError, match="empty object"):
          _utils.check_niimg([])
  
      # Test dimensionality error
      with pytest.raises(
          TypeError,
          match="Input data has incompatible dimensionality: "
          "Expected dimension is 3D and you provided a list "
          "of 3D images \\(4D\\).",
      ):
          _utils.check_niimg_3d([img_3d_zeros_eye, img_3d_zeros_eye])
  
      # Check that a filename does not raise an error
      data = np.zeros((40, 40, 40, 1))
      data[20, 20, 20] = 1
      data_img = Nifti1Image(data, affine_eye)
  
      filename = testing.write_imgs_to_path(
          data_img, file_path=tmp_path, create_files=True
      )
      _utils.check_niimg_3d(filename)
  
      # check data dtype equal with dtype='auto'
      img_check = _utils.check_niimg_3d(img_3d_zeros_eye, dtype="auto")
      assert (
          get_data(img_3d_zeros_eye).dtype.kind
          == get_data(img_check).dtype.kind
      )
  
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 2 for calling a global function with example usage: test_check_niimg_3d(affine_eye, img_3d_zeros_eye, tmp_path) without return types