code: def _interpolate_volumes(volumes, sample_mask, t_r, extrapolate):
      """Interpolate censored volumes in signals/confounds."""
      if extrapolate:
          extrapolate_default = (
              "By default the cubic spline interpolator extrapolates "
              "the out-of-bounds censored volumes in the data run. This "
              "can lead to undesired filtered signal results. Starting in "
              "version 0.13, the default strategy will be not to extrapolate "
              "but to discard those volumes at filtering."
          )
          warnings.warn(
              category=FutureWarning,
              message=extrapolate_default,
          )
      frame_times = np.arange(volumes.shape[0]) * t_r
      remained_vol = frame_times[sample_mask]
      remained_x = volumes[sample_mask, :]
      cubic_spline_fitter = CubicSpline(
          remained_vol, remained_x, extrapolate=extrapolate
      )
      volumes_interpolated = cubic_spline_fitter(frame_times)
      volumes[~sample_mask, :] = volumes_interpolated[~sample_mask, :]
      return volumes
  
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 12 for calling a global function with example usage: _interpolate_volumes(volumes, sample_mask, t_r, extrapolate) and returns: volumes