code: def test_shapelet_lengths():
      pytest.importorskip("tensorflow")
      from tslearn.shapelets import LearningShapelets
  
      # Test variable-length
      y = [0, 1]
      time_series = to_time_series_dataset([[1, 2, 3, 4, 5], [3, 2, 1]])
      clf = LearningShapelets(
          n_shapelets_per_size={3: 1},
          max_iter=1,
          verbose=0,
          random_state=0,
      )
      clf.fit(time_series, y)
  
      weights_shapelet = [np.array([[1, 2, 3]])]
      clf.set_weights(weights_shapelet, layer_name="shapelets_0_0")
      tr = clf.transform(time_series)
      np.testing.assert_allclose(tr, np.array([[0.0], [8.0 / 3]]))
  
      # Test max_size to predict longer series than those passed at fit time
      y = [0, 1]
      time_series = to_time_series_dataset([[1, 2, 3, 4, 5], [3, 2, 1]])
      clf = LearningShapelets(
          n_shapelets_per_size={3: 1},
          max_iter=1,
          verbose=0,
          max_size=6,
          random_state=0,
      )
      clf.fit(time_series[:, :-1], y)  # Fit with size 4
      weights_shapelet = [np.array([[1, 2, 3]])]
      clf.set_weights(weights_shapelet, layer_name="shapelets_0_0")
      tr = clf.transform(time_series)
      np.testing.assert_allclose(tr, np.array([[0.0], [8.0 / 3]]))
  
imports: import numpy
  import pytest
  from sklearn.model_selection import cross_validate
  from tslearn.utils import to_time_series, to_time_series_dataset
label_desc: Use image node_id 2 for calling a global function with example usage: test_shapelet_lengths() without return types