code: def create_fake_bids_dataset(
      base_dir=Path(),
      n_sub=10,
      n_ses=2,
      tasks=["localizer", "main"],
      n_runs=[1, 3],
      with_derivatives=True,
      with_confounds=True,
      confounds_tag="desc-confounds_timeseries",
      random_state=0,
      entities=None,
  ):
      """Create a fake :term:`BIDS` dataset directory with dummy files.
  
      Returns fake dataset directory name.
  
      Parameters
      ----------
      base_dir : :obj:`str` or :obj:`pathlib.Path` (Absolute path). \
          default=pathlib.Path()
          Absolute directory path in which to create the fake :term:`BIDS`
          dataset dir.
  
      n_sub : :obj:`int`, default=10
          Number of subjects to be simulated in the dataset.
  
      n_ses : :obj:`int`, default=2
          Number of sessions to be simulated in the dataset.
  
          Specifying n_ses=0 will only produce runs and files without the
          optional session field.
  
      tasks : :obj:`list` of :obj:`str`, default=["localizer", "main"]
          List of tasks to be simulated in the dataset.
  
      n_runs : :obj:`list` of :obj:`int`, default=[1, 3]
          Number of runs to create, where each element indicates the
          number of runs for the corresponding task.
          The length of this list must match the number of items in ``tasks``.
          Each run creates 100 volumes.
          Files will be generated without run entity
          if a value is equal to 0 or less.
  
      with_derivatives : :obj:`bool`, default=True
          In the case derivatives are included, they come with two spaces and
          descriptions.
          Spaces are 'MNI' and 'T1w'.
          Descriptions are 'preproc' and :term:`fMRIPrep`.
          Only space 'T1w' include both descriptions.
  
      with_confounds : :obj:`bool`, default=True
          Whether to generate associated confounds files or not.
  
      confounds_tag : :obj:`str`, default="desc-confounds_timeseries"
          Filename "suffix":
          If generating confounds, what path should they have?
          Defaults to `desc-confounds_timeseries` as in :term:`fMRIPrep` >= 20.2
          but can be other values (e.g. "desc-confounds_regressors" as
          in :term:`fMRIPrep` < 20.2).
  
      random_state : :obj:`int` or :obj:`numpy.random.RandomState` instance. \
                      default=0
          Random number generator, or seed.
  
      entities : :obj:`dict`, optional
          Extra entity to add to the :term:`BIDS` filename with a list of values.
          For example, if you want to add an 'echo' entity
          with values '1' for some files and '1' for others,
          you would pass: ``entities={"echo": ['1', '2']}``.
  
      Returns
      -------
      dataset directory name : :obj:`pathlib.Path`
          'bids_dataset'.
  
      Notes
      -----
          Creates a directory with dummy files.
  
      """
      n_voxels = 4
  
      rand_gen = np.random.default_rng(random_state)
  
      bids_dataset_dir = "bids_dataset"
      bids_path = Path(base_dir) / bids_dataset_dir
  
      for task_ in tasks:
          check_bids_label(task_)
  
      if not isinstance(n_runs, list) or not all(
          isinstance(x, int) for x in n_runs
      ):
          raise TypeError("n_runs must be a list of integers.")
  
      if len(tasks) != len(n_runs):
          raise ValueError(
              "The number of tasks and number of runs must be the same."
              f"Got {len(tasks)} tasks and {len(n_runs)} runs."
          )
  
      if entities is None:
          entities = {}
      _check_entities_and_labels(entities)
  
      _mock_bids_dataset(
          bids_path=bids_path,
          n_sub=n_sub,
          n_ses=n_ses,
          tasks=tasks,
          n_runs=n_runs,
          entities=entities,
          n_voxels=n_voxels,
          rand_gen=rand_gen,
      )
  
      if with_derivatives:
          if not with_confounds:
              confounds_tag = None
  
          _mock_bids_derivatives(
              bids_path=bids_path,
              n_sub=n_sub,
              n_ses=n_ses,
              tasks=tasks,
              n_runs=n_runs,
              confounds_tag=confounds_tag,
              entities=entities,
              n_voxels=n_voxels,
              rand_gen=rand_gen,
          )
  
      return bids_path
  
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 17 for calling a global function with example usage: create_fake_bids_dataset(base_dir, n_sub, n_ses, tasks, n_runs, with_derivatives, with_confounds, confounds_tag, random_state, entities) and returns: bids_path