code: def check_run_sample_masks(n_runs, sample_masks):
      """Check that number of sample_mask matches number of runs."""
      if not isinstance(sample_masks, (list, tuple, np.ndarray)):
          raise TypeError(
              f"sample_mask has an unhandled type: {sample_masks.__class__}"
          )
  
      if isinstance(sample_masks, np.ndarray):
          sample_masks = (sample_masks,)
  
      checked_sample_masks = [
          _convert_bool2index(sm) for sm in sample_masks
      ]
  
      if len(checked_sample_masks) != n_runs:
          raise ValueError(
              f"Number of sample_mask ({len(checked_sample_masks)}) not "
              f"matching number of runs ({n_runs})."
          )
      return checked_sample_masks
  
file_path: nilearn/nilearn/_utils/param_validation.py
imports: import numbers
  import warnings
  import numpy
  from sklearn.feature_selection import SelectPercentile, f_classif, f_regression
  from .niimg import _get_data
label_desc: Use image node_id 5 for calling a global function with example usage: check_run_sample_masks(n_runs, sample_masks) and returns: checked_sample_masks