code: def generate_mni_space_img(
      n_scans=1, res=30, random_state=0, mask_dilation=2
  ):
      """Generate MNI space img.
  
      Parameters
      ----------
      n_scans : :obj:`int`, default=1
          Number of scans.
  
      res : :obj:`int`, default=30
          Desired resolution, in mm, of output images.
  
      random_state : :obj:`int` or :obj:`numpy.random.RandomState` instance, \
                     default=0
          Random number generator, or seed.
  
      mask_dilation : :obj:`int`, default=2
          The number of times the binary :term:`dilation<Dilation>` is repeated
          on the mask.
  
      Returns
      -------
      inverse_img : Niimg-like object
          Image transformed back to MNI space.
  
      mask_img : Niimg-like object
          Generated mask in MNI space.
  
      """
      rand_gen = np.random.default_rng(random_state)
      mask_img = datasets.load_mni152_brain_mask(resolution=res)
      masker = maskers.NiftiMasker(mask_img).fit()
      n_voxels = image.get_data(mask_img).sum()
      data = rand_gen.standard_normal((n_scans, n_voxels))
      if mask_dilation is not None and mask_dilation > 0:
          mask_img = image.new_img_like(
              mask_img,
              binary_dilation(
                  image.get_data(mask_img), iterations=mask_dilation
              ),
          )
      inverse_img = masker.inverse_transform(data)
      return inverse_img, mask_img
  
imports: from __future__ import annotations
  import itertools
  import json
  import string
  from pathlib import Path
  import numpy
  import pandas
  import scipy.linalg
  import scipy.signal
  from nibabel import Nifti1Image
  from scipy.ndimage import binary_dilation
  from nilearn import datasets, image, maskers, masking
  from nilearn._utils import as_ndarray, logger
  from nilearn.interfaces.bids.utils import bids_entities, check_bids_label, create_bids_filename
  from nilearn.interfaces.fmriprep.tests._testing import get_legal_confound
label_desc: Use image node_id 1 for calling a global function with example usage: generate_mni_space_img(n_scans, res, random_state, mask_dilation) and returns: inverse_img,  mask_img