code: def to_sklearn_dataset(dataset, dtype=float, return_dim=False):
      """Transforms a time series dataset so that it fits the format used in
      ``sklearn`` estimators.
  
      Parameters
      ----------
      dataset : array-like
          The dataset of time series to be transformed.
      dtype : data type (default: float64)
          Data type for the returned dataset.
      return_dim : boolean  (optional, default: False)
          Whether the dimensionality (third dimension should be returned together
          with the transformed dataset).
  
      Returns
      -------
      numpy.ndarray of shape (n_ts, sz * d)
          The transformed dataset of time series.
      int (optional, if return_dim=True)
          The dimensionality of the original tslearn dataset (third dimension)
  
      Examples
      --------
      >>> to_sklearn_dataset([[1, 2]], return_dim=True)
      (array([[1., 2.]]), 1)
      >>> to_sklearn_dataset([[1, 2], [1, 4, 3]])
      array([[ 1.,  2., nan],
             [ 1.,  4.,  3.]])
  
      See Also
      --------
      to_time_series_dataset : Transforms a time series dataset to ``tslearn``
      format.
      """
      tslearn_dataset = to_time_series_dataset(dataset, dtype=dtype)
      n_ts = tslearn_dataset.shape[0]
      d = tslearn_dataset.shape[2]
      if return_dim:
          return tslearn_dataset.reshape((n_ts, -1)), d
      else:
          return tslearn_dataset.reshape((n_ts, -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 1 for calling a global function with example usage: to_sklearn_dataset(dataset, dtype, return_dim) and returns: tslearn_dataset,  d, tslearn_dataset