code: def to_pyts_dataset(X):
      """Transform a tslearn-compatible dataset into a pyts dataset.
  
      Parameters
      ----------
      X: array, shape = (n_ts, sz, d)
          tslearn-formatted dataset to be cast to pyts format
  
      Returns
      -------
      array, shape=(n_ts, sz) if d=1, (n_ts, d, sz) otherwise
          pyts-formatted dataset
  
      Examples
      --------
      >>> tslearn_arr = numpy.random.randn(10, 16, 1)
      >>> pyts_arr = to_pyts_dataset(tslearn_arr)
      >>> pyts_arr.shape
      (10, 16)
      >>> tslearn_arr = numpy.random.randn(10, 16, 2)
      >>> pyts_arr = to_pyts_dataset(tslearn_arr)
      >>> pyts_arr.shape
      (10, 2, 16)
      >>> tslearn_arr = [numpy.random.randn(16, 1), numpy.random.randn(10, 1)]
      >>> to_pyts_dataset(tslearn_arr)  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ...
      ValueError: All the time series in the array should be of equal lengths
      """
      X_ = check_dataset(X, force_equal_length=True)
      if X_.shape[2] == 1:
          return X_.reshape((X_.shape[0], -1))
      else:
          return X_.transpose((0, 2, 1))
  
file_path: tslearn/tslearn/utils/cast.py
imports: import warnings
  import numpy
  from sklearn.utils import check_array
  from .utils import check_dataset, ts_size, to_time_series_dataset
label_desc: Use image node_id 2 for calling a global function with example usage: to_pyts_dataset(X) and returns: X_, X_