code: def generate_maps(
      shape,
      n_regions,
      overlap=0,
      border=1,
      window="boxcar",
      random_state=0,
      affine=np.eye(4),
  ):
      """Generate a 4D volume containing several maps.
  
      Parameters
      ----------
      n_regions : :obj:`int`
          Number of regions to generate.
  
      overlap : :obj:`int`, default=0
          Approximate number of voxels common to two neighboring regions.
  
      window : :obj:`str`, default='boxcar'
          Name of a window in scipy.signal. Used to get non-uniform regions.
  
      random_state : :obj:`int` or :obj:`numpy.random.RandomState` instance, \
                     default=0
          Random number generator, or seed.
  
      affine : :obj:`numpy.ndarray`, default=np.eye(4)
          Affine transformation to use.
  
      border : :obj:`int`, default=1
          Number of background voxels on each side of the 3D volumes.
  
      Returns
      -------
      maps : Niimg-like object
          4D image object containing the maps.
  
      mask_img : Niimg-like object
          3D mask giving non-zero voxels.
  
      """
      mask = np.zeros(shape, dtype=np.int8)
      mask[border:-border, border:-border, border:-border] = 1
      ts = generate_regions_ts(
          mask.sum(),
          n_regions,
          overlap=overlap,
          random_state=random_state,
          window=window,
      )
      mask_img = Nifti1Image(mask, affine)
      return masking.unmask(ts, mask_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 4 for calling a global function with example usage: generate_maps(shape, n_regions, overlap, border, window, random_state, affine) and returns: masking,  mask_img