code: def create_tmp_filepath(
      base_path,
      image_type="regular",
      bids_fields=None,
      copy_confounds=False,
      copy_json=False,
      fmriprep_version="1.4.x",
  ):
      entities_to_include = [
          *bids_entities()["raw"],
          *bids_entities()["derivatives"],
      ]
      if bids_fields is None:
          bids_fields = {
              "entities": {
                  "sub": fmriprep_version.replace(".", ""),
                  "task": "test",
              }
          }
  
      """Create test files in temporary directory."""
      derivative = (
          "regressors" if fmriprep_version == "1.2.x" else "timeseries"
      )
  
      # confound files
      bids_fields["entities"]["desc"] = "confounds"
      bids_fields["suffix"] = derivative
      bids_fields["extension"] = "tsv"
      confounds_filename = create_bids_filename(
          fields=bids_fields, entities_to_include=entities_to_include
      )
      tmp_conf = base_path / confounds_filename
  
      if copy_confounds:
          conf, meta = get_legal_confound(
              fmriprep_version=fmriprep_version
          )
          conf.to_csv(tmp_conf, sep="\t", index=False)
      else:
          tmp_conf.touch()
  
      if copy_json:
          bids_fields["extension"] = "json"
          confounds_sidecar = create_bids_filename(
              fields=bids_fields,
              entities_to_include=entities_to_include,
          )
          tmp_meta = base_path / confounds_sidecar
          conf, meta = get_legal_confound(
              fmriprep_version=fmriprep_version
          )
          with open(tmp_meta, "w") as file:
              json.dump(meta, file, indent=2)
  
      # image data
      # convert path object to string as nibabel do strings
      img_file_patterns_type = img_file_patterns[image_type]
      if type(img_file_patterns_type) is dict:
          bids_fields = update_bids_fields(
              bids_fields, img_file_patterns_type
          )
          tmp_img = create_bids_filename(
              fields=bids_fields,
              entities_to_include=entities_to_include,
          )
          tmp_img = base_path / tmp_img
          tmp_img.touch()
          tmp_img = str(tmp_img)
      else:
          tmp_img = []
          for root in img_file_patterns_type:
              bids_fields = update_bids_fields(bids_fields, root)
              tmp_gii = create_bids_filename(
                  fields=bids_fields,
                  entities_to_include=entities_to_include,
              )
              tmp_gii = base_path / tmp_gii
              tmp_gii.touch()
              tmp_img.append(str(tmp_gii))
      return tmp_img, tmp_conf
  
file_path: nilearn/nilearn/interfaces/fmriprep/tests/_testing.py
imports: import json
  import os
  import pandas
  from nilearn.interfaces.bids.utils import bids_entities, create_bids_filename
  from nilearn.interfaces.fmriprep import load_confounds_utils
label_desc: Use image node_id 2 for calling a global function with example usage: create_tmp_filepath(base_path, image_type, bids_fields, copy_confounds, copy_json, fmriprep_version) and returns: tmp_img,  tmp_conf