code: def _add_nans_to_img(img, affine_mni=_affine_mni()):
      """Add nans in test image data."""
      data = get_data(img)
      data[6, 5, 1] = np.nan
      data[1, 5, 2] = np.nan
      data[1, 3, 2] = np.nan
      data[6, 5, 2] = np.inf
      return Nifti1Image(data, affine_mni)
  
imports: import matplotlib.pyplot
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from nilearn.conftest import _affine_mni
  from nilearn.datasets import load_mni152_template
  from nilearn.image import get_data, reorder_img
  from nilearn.plotting import plot_anat, plot_carpet, plot_epi, plot_glass_brain, plot_img, plot_prob_atlas, plot_roi, plot_stat_map
  from nilearn.plotting.img_plotting import MNI152TEMPLATE
label_desc: Use image node_id 1 for calling a global function with example usage: _add_nans_to_img(img, affine_mni) and returns: Nifti1Image