code: def _sanitize_sample_mask(n_time, n_runs, runs, sample_mask):
      """Check sample_mask is the right data type and matches the run index."""
      if sample_mask is None:
          return sample_mask
  
      sample_mask = check_run_sample_masks(n_runs, sample_mask)
  
      if runs is None:
          runs = np.zeros(n_time)
  
      # check sample mask of each run
      for i, current_mask in enumerate(sample_mask):
          _check_sample_mask_index(i, n_runs, runs, current_mask)
  
      return sample_mask[0] if sum(runs) == 0 else sample_mask
  
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 18 for calling a global function with example usage: _sanitize_sample_mask(n_time, n_runs, runs, sample_mask) and returns: unknown, sample_mask