code: def test_variable_length_knn():
      X = to_time_series_dataset(
          [[1, 2, 3, 4], [1, 2, 3], [9, 8, 7, 6, 5, 2], [8, 7, 6, 5, 3]]
      )
      y = [0, 0, 1, 1]
  
      clf = KNeighborsTimeSeriesClassifier(metric="dtw", n_neighbors=1)
      clf.fit(X, y)
      assert_allclose(clf.predict(X), [0, 0, 1, 1])
  
      clf = KNeighborsTimeSeriesClassifier(
          metric="softdtw", n_neighbors=1
      )
      clf.fit(X, y)
      assert_allclose(clf.predict(X), [0, 0, 1, 1])
  
      scaler = TimeSeriesScalerMeanVariance()
      clf = KNeighborsTimeSeriesClassifier(
          metric="sax", n_neighbors=1, metric_params={"n_segments": 2}
      )
      X_transf = scaler.fit_transform(X)
      clf.fit(X_transf, y)
      assert_allclose(clf.predict(X_transf), [0, 0, 1, 1])
  
file_path: tslearn/tslearn/tests/test_variablelength.py
imports: import numpy
  from numpy.testing import assert_allclose, assert_array_less
  from sklearn.model_selection import cross_val_score, KFold
  from tslearn.neighbors import KNeighborsTimeSeriesClassifier
  from tslearn.preprocessing import TimeSeriesScalerMeanVariance
  from tslearn.svm import TimeSeriesSVC, TimeSeriesSVR
  from tslearn.clustering import KernelKMeans, TimeSeriesKMeans
  from tslearn.utils import to_time_series_dataset
label_desc: Use image node_id 1 for calling a global function with example usage: test_variable_length_knn() without return types