code: def _diagonal_averaging(
      X,
      n_samples,
      n_timestamps,
      window_size,
      n_windows,
      grouping_size,
      gap,
  ):
      X_new = np.empty((n_samples, grouping_size, n_timestamps))
      first_row = [(0, col) for col in range(n_windows)]
      last_col = [(row, n_windows - 1) for row in range(1, window_size)]
      indices = first_row + last_col
      for i in prange(n_samples):
          for group in prange(grouping_size):
              for j, k in indices:
                  X_new[i, group, j + k] = np.diag(
                      X[i, group, :, ::-1], gap - j - k - 1
                  ).mean()
      return X_new
  
file_path: pyts/pyts/decomposition/ssa.py
imports: import numpy
  from math import ceil
  from numba import njit, prange
  from joblib import Parallel, delayed
  from sklearn.base import BaseEstimator
  from sklearn.utils.validation import check_array
  from ..base import UnivariateTransformerMixin
  from ..utils.utils import _windowed_view
label_desc: Use image node_id 2 for calling a global function with example usage: _diagonal_averaging(X, n_samples, n_timestamps, window_size, n_windows, grouping_size, gap) and returns: X_new