code: def _delay_time_series(X, tmin, tmax, sfreq, fill_mean=False):
      """Return a time-lagged input time series.
  
      Parameters
      ----------
      X : array, shape (n_times[, n_epochs], n_features)
          The time series to delay. Must be 2D or 3D.
      tmin : int | float
          The starting lag.
      tmax : int | float
          The ending lag.
          Must be >= tmin.
      sfreq : int | float
          The sampling frequency of the series. Defaults to 1.0.
      fill_mean : bool
          If True, the fill value will be the mean along the time dimension
          of the feature, and each cropped and delayed segment of data
          will be shifted to have the same mean value (ensuring that mean
          subtraction works properly). If False, the fill value will be zero.
  
      Returns
      -------
      delayed : array, shape(n_times[, n_epochs][, n_features], n_delays)
          The delayed data. It has the same shape as X, with an extra dimension
          appended to the end.
  
      Examples
      --------
      >>> tmin, tmax = -0.1, 0.2
      >>> sfreq = 10.
      >>> x = np.arange(1, 6)
      >>> x_del = _delay_time_series(x, tmin, tmax, sfreq)
      >>> print(x_del)  # doctest:+SKIP
      [[2. 1. 0. 0.]
       [3. 2. 1. 0.]
       [4. 3. 2. 1.]
       [5. 4. 3. 2.]
       [0. 5. 4. 3.]]
      """
      _check_delayer_params(tmin, tmax, sfreq)
      delays = _times_to_delays(tmin, tmax, sfreq)
      # Iterate through indices and append
      delayed = np.zeros(X.shape + (len(delays),))
      if fill_mean:
          mean_value = X.mean(axis=0)
          if X.ndim == 3:
              mean_value = np.mean(mean_value, axis=0)
          delayed[:] = mean_value[:, np.newaxis]
      for ii, ix_delay in enumerate(delays):
          # Create zeros to populate w/ delays
          if ix_delay < 0:
              out = delayed[:ix_delay, ..., ii]
              use_X = X[-ix_delay:]
          elif ix_delay > 0:
              out = delayed[ix_delay:, ..., ii]
              use_X = X[:-ix_delay]
          else:  # == 0
              out = delayed[..., ii]
              use_X = X
          out[:] = use_X
          if fill_mean:
              out[:] += mean_value - use_X.mean(axis=0)
      return delayed
  
imports: import numbers
  import numpy
  from scipy.stats import pearsonr
  from ..fixes import pinv
  from ..utils import _validate_type, fill_doc, verbose
  from .base import BaseEstimator, _check_estimator, get_coef
  from .time_delaying_ridge import TimeDelayingRidge
label_desc: Use image node_id 1 for calling a global function with example usage: _delay_time_series(X, tmin, tmax, sfreq, fill_mean) and returns: delayed