code: def _bids_path_template(
      task,
      suffix,
      n_runs=None,
      space=None,
      desc=None,
      extra_entity=None,
  ):
      """Create a BIDS filepath from a template.
  
      File path is relative to the BIDS root folder.
  
      File path contains a session level folder.
  
      """
      task = f"task-{task}_*"
      run = "run-*_*" if n_runs is not None else "*"
      space = f"space-{space}_*" if space is not None else "*"
      desc = f"desc-{desc}_*" if desc is not None else "*"
  
      # only using with resolution and acquisition entities (for now)
      acq = "*"
      res = "*"
      if extra_entity is not None:
          if "acq" in extra_entity:
              acq = f"acq-{extra_entity['acq']}_*"
          elif "res" in extra_entity:
              res = f"res-{extra_entity['res']}_*"
  
      path = "sub-*/ses-*/func/sub-*_ses-*_*"
      path += f"{task}{acq}{run}{space}{res}{desc}{suffix}"
      # TODO use regex
      path = path.replace("***", "*")
      path = path.replace("**", "*")
      return path
  
imports: from __future__ import annotations
  import json
  import numpy
  import pytest
  from nilearn._utils.data_gen import add_metadata_to_bids_dataset, create_fake_bids_dataset, generate_fake_fmri, generate_labeled_regions, generate_maps, generate_regions_ts
  from nilearn.image import get_data
label_desc: Use image node_id 3 for calling a global function with example usage: _bids_path_template(task, suffix, n_runs, space, desc, extra_entity) and returns: path