code: def check_dims(
      X, X_fit_dims=None, extend=True, check_n_features_only=False
  ):
      """Reshapes X to a 3-dimensional array of X.shape[0] univariate
      timeseries of length X.shape[1] if X is 2-dimensional and extend
      is True. Then checks whether the provided X_fit_dims and the
      dimensions of X (except for the first one), match.
  
      Parameters
      ----------
      X : array-like
          The first array to be compared.
      X_fit_dims : tuple (default: None)
          The dimensions of the data generated by fit, to compare with
          the dimensions of the provided array X.
          If None, then only perform reshaping of X, if necessary.
      extend : boolean (default: True)
          Whether to reshape X, if it is 2-dimensional.
      check_n_features_only: boolean (default: False)
  
      Returns
      -------
      array
          Reshaped X array
  
      Examples
      --------
      >>> X = numpy.empty((10, 3))
      >>> check_dims(X).shape
      (10, 3, 1)
      >>> X = numpy.empty((10, 3, 1))
      >>> check_dims(X).shape
      (10, 3, 1)
      >>> X_fit_dims = (5, 3, 1)
      >>> check_dims(X, X_fit_dims).shape
      (10, 3, 1)
      >>> X_fit_dims = (5, 3, 2)
      >>> check_dims(X, X_fit_dims)  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ValueError: Dimensions (except first) must match! ((5, 3, 2) and (10, 3, 1)
      are passed shapes)
      >>> X_fit_dims = (5, 5, 1)
      >>> check_dims(X, X_fit_dims, check_n_features_only=True).shape
      (10, 3, 1)
      >>> X_fit_dims = (5, 5, 2)
      >>> check_dims(
      ...     X,
      ...     X_fit_dims,
      ...     check_n_features_only=True
      ... )  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ValueError: Number of features of the provided timeseries must match!
      (last dimension) must match the one of the fitted data!
      ((5, 5, 2) and (10, 3, 1) are passed shapes)
  
      Raises
      ------
      ValueError
          Will raise exception if X is None or (if X_fit_dims is provided) one
          of the dimensions of the provided data, except the first, does not
          match X_fit_dims.
      """
      if X is None:
          raise ValueError("X is equal to None!")
  
      if extend and len(X.shape) == 2:
          warnings.warn(
              "2-Dimensional data passed. Assuming these are "
              "{} 1-dimensional timeseries".format(X.shape[0])
          )
          X = X.reshape((X.shape) + (1,))
  
      if X_fit_dims is not None:
          if check_n_features_only:
              if X_fit_dims[2] != X.shape[2]:
                  raise ValueError(
                      "Number of features of the provided timeseries"
                      "(last dimension) must match the one of the fitted data!"
                      " ({} and {} are passed shapes)".format(
                          X_fit_dims, X.shape
                      )
                  )
          else:
              if X_fit_dims[1:] != X.shape[1:]:
                  raise ValueError(
                      "Dimensions of the provided timeseries"
                      "(except first) must match those of the fitted data!"
                      " ({} and {} are passed shapes)".format(
                          X_fit_dims, X.shape
                      )
                  )
  
      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 1 for calling a global function with example usage: check_dims(X, X_fit_dims, extend, check_n_features_only) and returns: X