code: def temporal_split(X, y, test_size=0.25):
      """
      Split time series or sequence data along the time axis.
      Test data is drawn from the end of each series / sequence
  
      Parameters
      ----------
      X : array-like, shape [n_series, ...]
         Time series data and (optionally) contextual data
      y : array-like shape [n_series, ]
          target vector
      test_size : float
          between 0 and 1, amount to allocate to test
  
      Returns
      -------
      X_train : array-like, shape [n_series, ]
      X_test : array-like, shape [n_series, ]
      y_train :  array-like, shape [n_series, ]
      y_test :  array-like, shape [n_series, ]
  
      """
  
      if test_size <= 0.0 or test_size >= 1.0:
          raise ValueError(
              "temporal_split: test_size must be >= 0.0 and <= 1.0"
              " (was %.1f)" % test_size
          )
  
      Ns = len(y)  # number of series
      check_ts_data(X, y)
      Xt, Xc = get_ts_data_parts(X)
  
      train_size = 1.0 - test_size
  
      train_ind = [
          np.arange(0, int(train_size * len(Xt[i]))) for i in range(Ns)
      ]
      test_ind = [
          np.arange(len(train_ind[i]), len(Xt[i])) for i in range(Ns)
      ]
  
      X_train = [Xt[i][train_ind[i]] for i in range(Ns)]
      X_test = [Xt[i][test_ind[i]] for i in range(Ns)]
  
      if Xc is not None:
          X_train = TS_Data(X_train, Xc)
          X_test = TS_Data(X_test, Xc)
  
      if len(np.atleast_1d(y[0])) == len(Xt[0]):
          # y is a time series
          y_train = [y[i][train_ind[i]] for i in range(Ns)]
          y_test = [y[i][test_ind[i]] for i in range(Ns)]
      else:
          # y is contextual
          y_train = y
          y_test = y
  
      return X_train, X_test, y_train, y_test
  
file_path: seglearn/seglearn/split.py
imports: import numpy
  from sklearn.model_selection._split import _build_repr
  from .util import check_ts_data, get_ts_data_parts
  from .base import TS_Data
label_desc: Use image node_id 1 for calling a global function with example usage: temporal_split(X, y, test_size) and returns: X_train,  X_test,  y_train,  y_test