code: def write_fake_fmri_data_and_design(
      shapes, rk=3, affine=np.eye(4), random_state=0, file_path=None
  ):
      """Generate random :term:`fMRI` data \
      and design matrices and write them to disk.
  
      Parameters
      ----------
      shapes : :obj:`list` of :obj:`tuple`s of :obj:`int`
          A list of shapes in tuple format.
  
      rk : :obj:`int`, default=3
          Number of columns in the design matrix to be generated.
  
      affine : :obj:`numpy.ndarray`, default=np.eye(4)
          Affine of returned images.
  
      random_state : :obj:`int` or :obj:`numpy.random.RandomState` instance, \
                     default=0
          Random number generator, or seed.
  
      file_path : :obj:`str` or :obj:`pathlib.Path`, default=None
          Output file path.
  
      Returns
      -------
      mask_file : :obj:`str`
          Path to mask file.
  
      fmri_files : :obj:`list` of :obj:`str`
          A list of paths to the generated fmri files.
  
      design_files : :obj:`list` of :obj:`str`
          A list of paths to the generated design matrix files.
  
      See Also
      --------
      nilearn._utils.data_gen.generate_fake_fmri_data_and_design
  
      """
      if file_path is None:
          file_path = Path.cwd()
  
      mask_file, fmri_files, design_files = (
          file_path / "mask.nii",
          [],
          [],
      )
  
      rand_gen = np.random.default_rng(random_state)
      for i, shape in enumerate(shapes):
          data = rand_gen.standard_normal(shape)
          data[1:-1, 1:-1, 1:-1] += 100
          fmri_files.append(str(file_path / f"fmri_run{i:d}.nii"))
          Nifti1Image(data, affine).to_filename(fmri_files[-1])
  
          design_files.append(str(file_path / f"dmtx_{i:d}.csv"))
          pd.DataFrame(
              rand_gen.standard_normal((shape[3], rk)),
              columns=["", "", ""],
          ).to_csv(design_files[-1])
  
      Nifti1Image(
          (rand_gen.random(shape[:3]) > 0.5).astype(np.int8), affine
      ).to_filename(mask_file)
  
      return mask_file, fmri_files, design_files
  
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 8 for calling a global function with example usage: write_fake_fmri_data_and_design(shapes, rk, affine, random_state, file_path) and returns: mask_file,  fmri_files,  design_files