code: def _check_args_first_level_from_bids(
      dataset_path,
      task_label,
      space_label,
      sub_labels,
      img_filters,
      derivatives_folder,
  ):
      """Check type and value of arguments of first_level_from_bids.
  
      Check that:
          - dataset_path is a string and exists
          - derivatives_path exists
          - task_label and space_label are valid bids labels
          - img_filters is a list of tuples of strings
            and all filters are valid bids entities
            with valid bids labels
  
      Parameters
      ----------
      dataset_path : :obj:`str`
          Fullpath of the BIDS dataset root folder.
  
      task_label : :obj:`str`
          Task_label as specified in the file names like _task-<task_label>_.
  
      space_label : :obj:`str`
          Specifies the space label of the preprocessed bold.nii images.
          As they are specified in the file names like _space-<space_label>_.
  
      sub_labels : :obj:`list` of :obj:`str`, optional
          Specifies the subset of subject labels to model.
          If 'None', will model all subjects in the dataset.
  
      img_filters : :obj:`list` of :obj:`tuples` (str, str)
          Filters are of the form (field, label).
          Only one filter per field allowed.
  
      derivatives_path : :obj:`str`
          Fullpath of the BIDS dataset derivative folder.
  
      """
      if not isinstance(dataset_path, (str, Path)):
          raise TypeError(
              "'dataset_path' must be a string or pathlike. "
              f"Got {type(dataset_path)} instead."
          )
      dataset_path = Path(dataset_path)
      if not dataset_path.exists():
          raise ValueError(
              f"'dataset_path' does not exist:\n{dataset_path}"
          )
  
      if not isinstance(derivatives_folder, str):
          raise TypeError(
              "'derivatives_folder' must be a string. "
              f"Got {type(derivatives_folder)} instead."
          )
      derivatives_folder = dataset_path / derivatives_folder
      if not derivatives_folder.exists():
          raise ValueError(
              "derivatives folder not found in given dataset:\n"
              f"{derivatives_folder}"
          )
  
      check_bids_label(task_label)
  
      if space_label is not None:
          check_bids_label(space_label)
  
      if not isinstance(sub_labels, list):
          raise TypeError(
              f"sub_labels must be a list, instead {type(sub_labels)} was given"
          )
      for sub_label_ in sub_labels:
          check_bids_label(sub_label_)
  
      if not isinstance(img_filters, list):
          raise TypeError(
              f"'img_filters' must be a list. "
              f"Got {type(img_filters)} instead."
          )
      supported_filters = [
          *bids_entities()["raw"],
          *bids_entities()["derivatives"],
      ]
      for filter_ in img_filters:
          if len(filter_) != 2 or not all(
              isinstance(x, str) for x in filter_
          ):
              raise TypeError(
                  "Filters in img_filters must be (str, str). "
                  f"Got {filter_} instead."
              )
          if filter_[0] not in supported_filters:
              raise ValueError(
                  f"Entity {filter_[0]} for {filter_} is not a possible filter. "
                  f"Only {supported_filters} are allowed."
              )
          check_bids_label(filter_[1])
  
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 20 for calling a global function with example usage: _check_args_first_level_from_bids(dataset_path, task_label, space_label, sub_labels, img_filters, derivatives_folder) without return types