class_docstr: Unsupervised learner for implementing neighbor searches for Time Series.
  
  Parameters
  ----------
  n_neighbors : int (default: 5)
      Number of nearest neighbors to be considered for the decision.
  
  metric : {'dtw', 'softdtw', 'ctw', 'euclidean', 'sqeuclidean',               'cityblock',  'sax'} (default: 'dtw')
      Metric to be used at the core of the nearest neighbor procedure.
      DTW and SAX are described in more detail in :mod:`tslearn.metrics`.
      When SAX is provided as a metric, the data is expected to be
      normalized such that each time series has zero mean and unit
      variance. Other metrics are described in `scipy.spatial.distance doc
      <https://docs.scipy.org/doc/scipy/reference/spatial.distance.html>`_.
  
  metric_params : dict or None (default: None)
      Dictionary of metric parameters.
      For metrics that accept parallelization of the cross-distance matrix
      computations, `n_jobs` and `verbose` keys passed in `metric_params`
      are overridden by the `n_jobs` and `verbose` arguments.
      For 'sax' metric, these are hyper-parameters to be passed at the 
      creation of the `SymbolicAggregateApproximation` object.
  
  n_jobs : int or None, optional (default=None)
      The number of jobs to run in parallel for cross-distance matrix
      computations.
      Ignored if the cross-distance matrix cannot be computed using
      parallelization.
      ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
      ``-1`` means using all processors. See scikit-learns'
      `Glossary <https://scikit-learn.org/stable/glossary.html#term-n-jobs>`__
      for more details.
  
  Notes
  -----
      The training data are saved to disk if this model is
      serialized and may result in a large model file if the training
      dataset is large.
  
  Examples
  --------
  >>> time_series = to_time_series_dataset([[1, 2, 3, 4],
  ...                                       [3, 3, 2, 0],
  ...                                       [1, 2, 2, 4]])
  >>> knn = KNeighborsTimeSeries(n_neighbors=1).fit(time_series)
  >>> dataset = to_time_series_dataset([[1, 1, 2, 2, 2, 3, 4]])
  >>> dist, ind = knn.kneighbors(dataset, return_distance=True)
  >>> dist
  array([[0.]])
  >>> print(ind)
  [[0]]
  >>> knn2 = KNeighborsTimeSeries(n_neighbors=10,
  ...                             metric="euclidean").fit(time_series)
  >>> print(knn2.kneighbors(return_distance=False))
  [[2 1]
   [2 0]
   [0 1]]
docstr: Finds the K-neighbors of a point.
  
  Returns indices of and distances to the neighbors of each point.
  
  Parameters
  ----------
  X : array-like, shape (n_ts, sz, d)
      The query time series.
      If not provided, neighbors of each indexed point are returned.
      In this case, the query point is not considered its own neighbor.
  n_neighbors : int
      Number of neighbors to get (default is the value passed to the
      constructor).
  return_distance : boolean, optional. Defaults to True.
      If False, distances will not be returned
  
  Returns
  -------
  dist : array
      Array representing the distance to points, only present if
      return_distance=True
  ind : array
      Indices of the nearest points in the population matrix.
docstr_tok: ["Finds","the","K-neighbors","of","a","point",".","Returns","indices","of","and","distances","to","the","neighbors","of","each","point",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape","(","n_ts",",","sz",",","d",")","The","query","time","series",".","If","not","provided",",","neighbors","of","each","indexed","point","are","returned",".","In","this","case",",","the","query","point","is","not","considered","its","own","neighbor",".","n_neighbors",":","int","Number","of","neighbors","to","get","(","default","is","the","value","passed","to","the","constructor",")",".","return_distance",":","boolean",",","optional",".","Defaults","to","True",".","If","False",",","distances","will","not","be","returned","Returns","--","--","--","-","dist",":","array","Array","representing","the","distance","to","points",",","only","present","if","return_distance=True","ind",":","array","Indices","of","the","nearest","points","in","the","population","matrix","."]
code: def kneighbors(self, X=None, n_neighbors=None, return_distance=True):
      """Finds the K-neighbors of a point.
  
      Returns indices of and distances to the neighbors of each point.
  
      Parameters
      ----------
      X : array-like, shape (n_ts, sz, d)
          The query time series.
          If not provided, neighbors of each indexed point are returned.
          In this case, the query point is not considered its own neighbor.
      n_neighbors : int
          Number of neighbors to get (default is the value passed to the
          constructor).
      return_distance : boolean, optional. Defaults to True.
          If False, distances will not be returned
  
      Returns
      -------
      dist : array
          Array representing the distance to points, only present if
          return_distance=True
      ind : array
          Indices of the nearest points in the population matrix.
      """
      if self.metric in TSLEARN_VALID_METRICS:
          self._ts_metric = self.metric
          self.metric = "precomputed"
  
          metric_params = self._get_metric_params()
          check_is_fitted(self, "_ts_fit")
          X = check_array(X, allow_nd=True, force_all_finite=False)
          X = check_dims(
              X,
              X_fit_dims=self._ts_fit.shape,
              extend=True,
              check_n_features_only=True,
          )
          if self._ts_metric == "dtw":
              X_ = cdist_dtw(
                  X,
                  self._ts_fit,
                  n_jobs=self.n_jobs,
                  verbose=self.verbose,
                  **metric_params,
              )
          elif self._ts_metric == "ctw":
              X_ = cdist_ctw(X, self._ts_fit, **metric_params)
          elif self._ts_metric == "softdtw":
              X_ = cdist_soft_dtw(X, self._ts_fit, **metric_params)
          else:
              raise ValueError(
                  "Invalid metric recorded: %s" % self._ts_metric
              )
          pred = KNeighborsTimeSeriesMixin.kneighbors(
              self,
              X=X_,
              n_neighbors=n_neighbors,
              return_distance=return_distance,
          )
          self.metric = self._ts_metric
          return pred
      else:
          check_is_fitted(self, "_X_fit")
          if X is None:
              X_ = None
          else:
              X = check_array(X, allow_nd=True)
              X = to_time_series_dataset(X)
              X_ = to_sklearn_dataset(X)
              X_ = check_dims(
                  X_, X_fit_dims=self._X_fit.shape, extend=False
              )
          return KNeighborsTimeSeriesMixin.kneighbors(
              self,
              X=X_,
              n_neighbors=n_neighbors,
              return_distance=return_distance,
          )
  
imports: import numpy
  from sklearn import neighbors
  from sklearn.neighbors import KNeighborsClassifier, NearestNeighbors, KNeighborsRegressor
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from scipy.spatial.distance import cdist
  from tslearn.metrics import cdist_dtw, cdist_ctw, cdist_soft_dtw, cdist_sax, TSLEARN_VALID_METRICS
  from tslearn.piecewise import SymbolicAggregateApproximation
  from tslearn.utils import to_time_series_dataset, to_sklearn_dataset, check_dims
  from tslearn.bases import BaseModelPackage
label_desc: Use image node_id 5 for calling the KNeighborsTimeSeries obj's underlying member method code with example usage: obj.kneighbors(X, n_neighbors, return_distance) and returns: pred, KNeighborsTimeSeriesMixin