code: def time_series_reshaper(
      Xflat, numfeatures, subsample=1, differences=True
  ):
      """Convert 2D np.ndarray into a time series 3D np.ndarray.
  
      Useful as part of sklearn pipeline for internal conversion to time series 3D format.
  
      optionally, subsamples or differences time series
  
      Parameters
      ----------
      Xflat : 2D np.ndarray (instances, flattened time series)
      numfeatures : number of features/variables in the time series
      subsample : int, optional, default = 1
          time index step size to sub-sample
      differences : bool, optional, default = True
          whether to take first temporal differences (True) or not (False)
  
      Returns
      -------
      Xflat, as a 3D array
          regular subsampling is applied if subsample > 1
          differencing is applied (after subsampling) if differences=True
      """
      flatXshape = np.shape(Xflat)
      Xshape = (flatXshape[0], numfeatures, flatXshape[1] / numfeatures)
      X = np.reshape(Xflat, Xshape)[:, :, ::subsample]
  
      if differences:
          return np.diff(X)
      else:
          return X
  
imports: import collections
  from functools import partial
  import numpy
  from scipy.sparse.linalg import svds
  from sklearn.base import BaseEstimator, TransformerMixin
  from sktime.dists_kernels.base import BasePairwiseTransformerPanel
label_desc: Use image node_id 33 for calling a global function with example usage: time_series_reshaper(Xflat, numfeatures, subsample, differences) and returns: np, X