code: def from_pyts_dataset(X):
      """Transform a pyts-compatible dataset into a tslearn dataset.
  
      Parameters
      ----------
      X: array, shape = (n_ts, sz) or (n_ts, d, sz)
          pyts-formatted dataset
  
      Returns
      -------
      array, shape=(n_ts, sz, d)
          tslearn-formatted dataset
  
      Examples
      --------
      >>> pyts_arr = numpy.random.randn(10, 16)
      >>> tslearn_arr = from_pyts_dataset(pyts_arr)
      >>> tslearn_arr.shape
      (10, 16, 1)
      >>> pyts_arr = numpy.random.randn(10, 2, 16)
      >>> tslearn_arr = from_pyts_dataset(pyts_arr)
      >>> tslearn_arr.shape
      (10, 16, 2)
      >>> pyts_arr = numpy.random.randn(10)
      >>> from_pyts_dataset(pyts_arr)  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ...
      ValueError: X is not a valid input pyts array.
      """
      X_ = check_array(X, ensure_2d=False, allow_nd=True)
      if X_.ndim == 2:
          shape = list(X_.shape) + [1]
          return X_.reshape(shape)
      elif X_.ndim == 3:
          return X_.transpose((0, 2, 1))
      else:
          raise ValueError(
              "X is not a valid input pyts array. "
              "Its dimensions, once cast to numpy.ndarray "
              "are {}".format(X_.shape)
          )
  
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 3 for calling a global function with example usage: from_pyts_dataset(X) and returns: X_, X_