code: def check_dataset(
      X,
      force_univariate=False,
      force_equal_length=False,
      force_single_time_series=False,
  ):
      """Check if X is a valid tslearn dataset, with possibly additional extra
      constraints.
  
      Parameters
      ----------
      X: array-like, shape=(n_ts, sz, d)
          Time series dataset.
      force_univariate: bool (default: False)
          If True, only univariate datasets are considered valid.
      force_equal_length: bool (default: False)
          If True, only equal-length datasets are considered valid.
      force_single_time_series: bool (default: False)
          If True, only datasets made of a single time series are considered
          valid.
  
      Returns
      -------
      array-like, shape=(n_ts, sz, d)
          Formatted dataset, if it is valid
  
      Raises
      ------
      ValueError
          Raised if X is not a valid dataset, or one of the constraints is not
          satisfied.
  
      Examples
      --------
      >>> X = [[1, 2, 3], [1, 2, 3, 4]]
      >>> X_new = check_dataset(X)
      >>> X_new.shape
      (2, 4, 1)
      >>> check_dataset(
      ...     X,
      ...     force_equal_length=True
      ... )  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ...
      ValueError: All the time series in the array should be of equal lengths.
      >>> other_X = numpy.random.randn(3, 10, 2)
      >>> check_dataset(
      ...     other_X,
      ...     force_univariate=True
      ... )  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ...
      ValueError: Array should be univariate and is of shape: (3, 10, 2)
      >>> other_X = numpy.random.randn(3, 10, 2)
      >>> check_dataset(
      ...     other_X,
      ...     force_single_time_series=True
      ... )  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ...
      ValueError: Array should be made of a single time series (3 here)
      """
      X_ = to_time_series_dataset(X)
      if force_univariate and X_.shape[2] != 1:
          raise ValueError(
              "Array should be univariate and is of shape: {}".format(
                  X_.shape
              )
          )
      if force_equal_length and not check_equal_size(X_):
          raise ValueError(
              "All the time series in the array should be of "
              "equal lengths"
          )
      if force_single_time_series and X_.shape[0] != 1:
          raise ValueError(
              "Array should be made of a single time series "
              "({} here)".format(X_.shape[0])
          )
      return X_
  
imports: import warnings
  from io import StringIO
  import numpy
  from sklearn.base import TransformerMixin
  from sklearn.utils import column_or_1d
  from sklearn.utils.validation import check_is_fitted
  from tslearn.backend import instantiate_backend
  from tslearn.bases import TimeSeriesBaseEstimator
label_desc: Use image node_id 11 for calling a global function with example usage: check_dataset(X, force_univariate, force_equal_length, force_single_time_series) and returns: X_