class_docstr: KShape clustering for time series.
  
  KShape was originally presented in [1]_.
  
  Parameters
  ----------
  n_clusters : int (default: 3)
      Number of clusters to form.
  
  max_iter : int (default: 100)
      Maximum number of iterations of the k-Shape algorithm.
  
  tol : float (default: 1e-6)
      Inertia variation threshold. If at some point, inertia varies less than
      this threshold between two consecutive
      iterations, the model is considered to have converged and the algorithm
      stops.
  
  n_init : int (default: 1)
      Number of time the k-Shape algorithm will be run with different
      centroid seeds. The final results will be the
      best output of n_init consecutive runs in terms of inertia.
  
  verbose : bool (default: False)
      Whether or not to print information about the inertia while learning
      the model.
  
  random_state : integer or numpy.RandomState, optional
      Generator used to initialize the centers. If an integer is given, it
      fixes the seed. Defaults to the global
      numpy random number generator.
  
  init : {'random' or ndarray} (default: 'random')
      Method for initialization.
      'random': choose k observations (rows) at random from data for the
      initial centroids.
      If an ndarray is passed, it should be of shape (n_clusters, ts_size, d)
      and gives the initial centers.
  
  Attributes
  ----------
  cluster_centers_ : numpy.ndarray of shape (sz, d).
      Centroids
  
  labels_ : numpy.ndarray of integers with shape (n_ts, ).
      Labels of each point
  
  inertia_ : float
      Sum of distances of samples to their closest cluster center.
  
  n_iter_ : int
      The number of iterations performed during fit.
  
  Notes
  -----
      This method requires a dataset of equal-sized time series.
  
  Examples
  --------
  >>> from tslearn.generators import random_walks
  >>> X = random_walks(n_ts=50, sz=32, d=1)
  >>> X = TimeSeriesScalerMeanVariance(mu=0., std=1.).fit_transform(X)
  >>> ks = KShape(n_clusters=3, n_init=1, random_state=0).fit(X)
  >>> ks.cluster_centers_.shape
  (3, 32, 1)
  
  References
  ----------
  .. [1] J. Paparrizos & L. Gravano. k-Shape: Efficient and Accurate
     Clustering of Time Series. SIGMOD 2015. pp. 1855-1870.
docstr: Compute k-Shape clustering.
  
  Parameters
  ----------
  X : array-like of shape=(n_ts, sz, d)
      Time series dataset.
  
  y
      Ignored
docstr_tok: ["Compute","k-Shape","clustering",".","Parameters","--","--","--","--","--","X",":","array-like","of","shape=","(","n_ts",",","sz",",","d",")","Time","series","dataset",".","y","Ignored"]
code: def fit(self, X, y=None):
      """Compute k-Shape clustering.
  
      Parameters
      ----------
      X : array-like of shape=(n_ts, sz, d)
          Time series dataset.
  
      y
          Ignored
      """
      X = check_array(X, allow_nd=True)
  
      max_attempts = max(self.n_init, 10)
  
      self.labels_ = None
      self.inertia_ = numpy.inf
      self.cluster_centers_ = None
  
      self.norms_ = 0.0
      self.norms_centroids_ = 0.0
  
      self.n_iter_ = 0
  
      X_ = to_time_series_dataset(X)
      self._X_fit = X_
      self.norms_ = numpy.linalg.norm(X_, axis=(1, 2))
  
      _check_initial_guess(self.init, self.n_clusters)
  
      rs = check_random_state(self.random_state)
  
      best_correct_centroids = None
      min_inertia = numpy.inf
      n_successful = 0
      n_attempts = 0
      while n_successful < self.n_init and n_attempts < max_attempts:
          try:
              if self.verbose and self.n_init > 1:
                  print("Init %d" % (n_successful + 1))
              n_attempts += 1
              self._fit_one_init(X_, rs)
              if self.inertia_ < min_inertia:
                  best_correct_centroids = self.cluster_centers_.copy()
                  min_inertia = self.inertia_
                  self.n_iter_ = self._iter
              n_successful += 1
          except EmptyClusterError:
              if self.verbose:
                  print("Resumed because of empty cluster")
      self.norms_centroids_ = numpy.linalg.norm(
          self.cluster_centers_, axis=(1, 2)
      )
      self._post_fit(X_, best_correct_centroids, min_inertia)
      return self
  
imports: from sklearn.base import ClusterMixin
  from sklearn.utils import check_random_state
  import numpy
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from tslearn.preprocessing import TimeSeriesScalerMeanVariance
  from tslearn.utils import to_time_series_dataset, check_dims
  from tslearn.metrics import cdist_normalized_cc, y_shifted_sbd_vec
  from tslearn.bases import BaseModelPackage, TimeSeriesBaseEstimator
  from .utils import TimeSeriesCentroidBasedClusteringMixin, _check_no_empty_cluster, _compute_inertia, _check_initial_guess, EmptyClusterError
label_desc: Use image node_id 8 for calling the KShape obj's underlying member method code with example usage: obj.fit(X, y) and returns: self