code: def test_get_target_dtype(affine_eye):
      img = Nifti1Image(
          np.ones((2, 2, 2), dtype=np.float64), affine=affine_eye
      )
      assert get_data(img).dtype.kind == "f"
      dtype_kind_float = niimg._get_target_dtype(
          get_data(img).dtype, target_dtype="auto"
      )
      assert dtype_kind_float == np.float32
      # Passing dtype or header is required when using int64
      # https://nipy.org/nibabel/changelog.html#api-changes-and-deprecations
      hdr = Nifti1Header()
      hdr.set_data_dtype(np.int64)
      data = np.ones((2, 2, 2), dtype=np.int64)
      img2 = Nifti1Image(data, affine=affine_eye, header=hdr)
      assert (
          get_data(img2).dtype.kind == img2.get_data_dtype().kind == "i"
      )
      dtype_kind_int = niimg._get_target_dtype(
          get_data(img2).dtype, target_dtype="auto"
      )
      assert dtype_kind_int == np.int32
  
file_path: nilearn/nilearn/_utils/tests/test_niimg.py
imports: from pathlib import Path
  import joblib
  import nibabel
  import numpy
  import pytest
  from nibabel import Nifti1Header, Nifti1Image
  from nilearn._utils import load_niimg, niimg, testing
  from nilearn.image import get_data, new_img_like
label_desc: Use image node_id 3 for calling a global function with example usage: test_get_target_dtype(affine_eye) without return types