code: def _check_entities_and_labels(entities):
      """Check entities and labels are BIDS compliant.
  
      Parameters
      ----------
      entities : :obj:`dict`, optional
          Extra entity to add to the 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']}``.
      """
      if len(entities.keys()) > 1:
          # Generating dataset with more than one extra entity
          # becomes too complex.
          # Won't be implemented until there is a need.
          raise ValueError(
              "Only a single extra entity is supported for now."
          )
  
      for key in entities:
          if key not in [
              *bids_entities()["raw"],
              *bids_entities()["derivatives"],
          ]:
              allowed_entities = [
                  *bids_entities()["raw"],
                  *bids_entities()["derivatives"],
              ]
              raise ValueError(
                  f"Invalid entity: {key}. Allowed entities are: "
                  f"{allowed_entities}"
              )
          [check_bids_label(label_) for label_ in entities[key]]
  
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 18 for calling a global function with example usage: _check_entities_and_labels(entities) without return types