code: def _check_bids_events_list(
      events,
      imgs,
      sub_label,
      task_label,
      dataset_path,
      events_filters,
      verbose,
  ):
      """Check input BIDS events.
  
      Check that:
          - some events.tsv files were found
          - as many events.tsv were found as images
          - there is only one events.tsv per image and that they have the same
            raw entities.
  
      Parameters
      ----------
      events : :obj:`list` of :obj:`str` or None
          List of events.tsv fullpath filenames.
  
      imgs : :obj:`list` of :obj:`str`
          List of image fullpath filenames.
  
      sub_label : :obj:`str`
          Subject label as specified in the file names like sub-<sub_label>_.
  
      task_label : :obj:`str`
          Task label as specified in the file names like _task-<task_label>_.
  
      dataset_path : :obj:`str`
          Fullpath to the BIDS dataset.
  
      events_filters : :obj:`list` of :obj:`tuple` (str, str)
          Filters of the form (field, label) used to select the files.
          See :func:`get_bids_files`.
  
      """
      if not events:
          raise ValueError(
              "No events.tsv files found "
              f"for subject {sub_label} "
              f"for filter: {events_filters}."
          )
      if len(events) != len(imgs):
          raise ValueError(
              f"{len(events)} events.tsv files found"
              f" for {len(imgs)} bold files. "
              "Same number of event files "
              "as the number of runs is expected."
          )
      _check_trial_type(events=events)
  
      supported_filters = [
          "sub",
          "ses",
          "task",
          *bids_entities()["raw"],
      ]
      for this_img in imgs:
          parsed_filename = parse_bids_filename(this_img)
          extra_filter = [
              (key, parsed_filename[key])
              for key in parsed_filename
              if key in supported_filters
          ]
          filters = _make_bids_files_filter(
              task_label=task_label,
              space_label=None,
              supported_filters=supported_filters,
              extra_filter=extra_filter,
              verbose=verbose,
          )
          this_event = get_bids_files(
              dataset_path,
              modality_folder="func",
              file_tag="events",
              file_type="tsv",
              sub_label=sub_label,
              filters=filters,
          )
          msg_suffix = (
              f" bold file:\n{this_img}\nfilter:\n{filters})\n"
              "Found all the following events files "
              f"for filter:\n{events}\n"
          )
          if len(this_event) == 0:
              raise ValueError(
                  f"No events.tsv files "
                  f"corresponding to {msg_suffix}"
              )
          if len(this_event) > 1:
              raise ValueError(
                  f"More than 1 events.tsv files "
                  f"corresponding to {msg_suffix}"
              )
          if this_event[0] not in events:
              raise ValueError(
                  f"\n{this_event} not in {events}.\n"
                  "No corresponding events.tsv files found "
                  f"for {msg_suffix}"
              )
  
imports: from __future__ import annotations
  import csv
  import glob
  import os
  import sys
  import time
  from pathlib import Path
  from warnings import warn
  import numpy
  import pandas
  from joblib import Memory, Parallel, delayed
  from nibabel import Nifti1Image
  from sklearn.base import clone
  from sklearn.cluster import KMeans
  from nilearn._utils import fill_doc, stringify_path
  from nilearn._utils.niimg_conversions import check_niimg
  from nilearn._utils.param_validation import check_run_sample_masks
  from nilearn.glm._base import BaseGLM
  from nilearn.glm.contrasts import compute_fixed_effect_contrast, expression_to_contrast_vector
  from nilearn.glm.first_level.design_matrix import make_first_level_design_matrix
  from nilearn.glm.regression import ARModel, OLSModel, RegressionResults, SimpleRegressionResults
  from nilearn.image import get_data
  from nilearn.interfaces.bids import get_bids_files, parse_bids_filename
  from nilearn.interfaces.bids.query import infer_repetition_time_from_dataset, infer_slice_timing_start_time_from_dataset
  from nilearn.interfaces.bids.utils import bids_entities, check_bids_label
  from nilearn.interfaces.fmriprep.load_confounds import load_confounds
label_desc: Use image node_id 24 for calling a global function with example usage: _check_bids_events_list(events, imgs, sub_label, task_label, dataset_path, events_filters, verbose) without return types