code: def _check_sample_mask_index(i, n_runs, runs, current_mask):
      """Ensure the index in sample mask is valid."""
      len_run = sum(i == runs)
      len_current_mask = len(current_mask)
      # sample_mask longer than signal
      if len_current_mask > len_run:
          raise IndexError(
              f"sample_mask {i + 1} of {n_runs} is has more timepoints "
              f"than the current run ;sample_mask contains {len_current_mask} "
              f"index but the run has {len_run} timepoints."
          )
      # sample_mask index exceed signal timepoints
      invalid_index = current_mask[current_mask > len_run]
      if invalid_index.size > 0:
          raise IndexError(
              f"sample_mask {i + 1} of {n_runs} contains "
              f"invalid index {invalid_index}. "
              f"The signal contains {len_run} time points."
          )
  
imports: import warnings
  import numpy
  import pandas
  from scipy import linalg, signal
  from scipy.interpolate import CubicSpline
  from sklearn.utils import as_float_array, gen_even_slices
  from nilearn._utils import fill_doc, stringify_path
  from nilearn._utils.numpy_conversions import as_ndarray, csv_to_array
  from nilearn._utils.param_validation import check_run_sample_masks
label_desc: Use image node_id 19 for calling a global function with example usage: _check_sample_mask_index(i, n_runs, runs, current_mask) without return types