code: def extract_features(
      X, interval_indices, n_samples, n_subseries, n_intervals
  ):
      # There are 3 features for each interval (mean, std, slope) plus
      # the mean, std over the whole subsequence and indices of the subsequence
      n_features = n_intervals * 3 + 4
      X_features = np.zeros((n_samples * n_subseries, n_features))
  
      for j in range(n_subseries):
          for k in range(n_intervals):
              # Get the start and end indices of the interval
              start, end = interval_indices[:, j, k]
              arange = np.arange(
                  (start - end + 1) / 2, (end + 1 - start) / 2
              )
              if end - start == 1:
                  var_arange = 1.0
              else:
                  var_arange = np.sum(arange**2)
  
              for i in range(n_samples):
                  i_j = i * n_subseries + j
                  mean = np.mean(X[i, start:end])
  
                  # Compute the three statistics of the interval
                  X_features[i_j, 3 * k] = mean
                  X_features[i_j, 3 * k + 1] = np.std(X[i, start:end])
                  X_features[i_j, 3 * k + 2] = (
                      np.sum((X[i, start:end] - mean) * arange)
                      / var_arange
                  )
  
          start, end = (
              interval_indices[0, j, 0],
              interval_indices[1, j, -1],
          )
          for i in range(n_samples):
              i_j = i * n_subseries + j
  
              # Compute the four statistics of the subseries
              X_features[i_j, -4] = np.mean(X[i, start:end])
              X_features[i_j, -3] = np.std(X[i, start:end])
              X_features[i_j, -2] = start
              X_features[i_j, -1] = end
  
      return X_features
  
imports: from math import ceil
  from numba import njit
  import numpy
  from sklearn.base import BaseEstimator
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.utils.validation import check_array, check_is_fitted, check_random_state, check_X_y
  from ..base import UnivariateClassifierMixin, UnivariateTransformerMixin
label_desc: Use image node_id 1 for calling a global function with example usage: extract_features(X, interval_indices, n_samples, n_subseries, n_intervals) and returns: X_features