code: def _handle_scrubbed_volumes(
      signals, confounds, sample_mask, filter_type, t_r, extrapolate
  ):
      """Interpolate or censor scrubbed volumes."""
      if sample_mask is None:
          return signals, confounds, sample_mask
  
      if filter_type == "butterworth":
          signals = _interpolate_volumes(
              signals, sample_mask, t_r, extrapolate
          )
          # discard non-interpolated out-of-bounds volumes
          signals = signals[~np.isnan(signals).all(axis=1), :]
          if confounds is not None:
              confounds = _interpolate_volumes(
                  confounds, sample_mask, t_r, extrapolate
              )
              # discard non-interpolated out-of-bounds volumes
              confounds = confounds[~np.isnan(confounds).all(axis=1), :]
          if sample_mask is not None and not extrapolate:
              # reset the indexing of the sample_mask excluding non-interpolated
              # volumes at the head of the data
              sample_mask -= sample_mask[0]
      else:  # Or censor when no filtering, or cosine filter
          signals, confounds = _censor_signals(
              signals, confounds, sample_mask
          )
      return signals, confounds, 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 10 for calling a global function with example usage: _handle_scrubbed_volumes(signals, confounds, sample_mask, filter_type, t_r, extrapolate) and returns: signals,  confounds,  sample_mask, signals,  confounds,  sample_mask