code: def test_fake_bids_extra_derivative_entity(tmp_path):
      """Check files with extra entity are created appropriately."""
      n_sub = 2
      n_ses = 2
      tasks = ["main"]
      n_runs = [2]
      entities = {"res": ["foo", "bar"]}
      bids_path = create_fake_bids_dataset(
          base_dir=tmp_path,
          n_sub=n_sub,
          n_ses=n_ses,
          tasks=tasks,
          n_runs=n_runs,
          entities=entities,
      )
  
      # raw
      all_files = list(bids_path.glob("sub-*/ses-*/*/*res*"))
      assert not all_files
  
      # derivatives
      for label in entities["res"]:
          for task, n_run in zip(tasks, n_runs):
              _check_nb_files_derivatives_for_task(
                  bids_path=bids_path,
                  n_sub=n_sub,
                  n_ses=n_ses,
                  task=task,
                  n_run=n_run,
                  extra_entity={"res": label},
              )
  
      all_files = list(bids_path.glob("derivatives/sub-*/ses-*/*/*"))
      # per subject:
      # 1 confound per run per session
      # + (3 bold + 2 gifti) per run per session per entity
      n_derivatives_files_expected = n_sub * (
          2 * sum(n_runs) * n_ses
          + 5 * sum(n_runs) * n_ses * len(entities["res"])
      )
      assert len(all_files) == n_derivatives_files_expected
  
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 13 for calling a global function with example usage: test_fake_bids_extra_derivative_entity(tmp_path) without return types