code: def test_gak():
      for be in backends:
          for array_type in array_types:
              backend = instantiate_backend(be, array_type)
              # GAK
              g = tslearn.metrics.cdist_gak(
                  cast(
                      [[1, 2, 2, 3], [1.0, 2.0, 3.0, 4.0]], array_type
                  ),
                  sigma=2.0,
                  be=be,
              )
              np.testing.assert_allclose(
                  g,
                  np.array([[1.0, 0.656297], [0.656297, 1.0]]),
                  atol=1e-5,
              )
              assert backend.belongs_to_backend(g)
              g = tslearn.metrics.cdist_gak(
                  [
                      [1, 2, 2],
                      [1.0, 2.0, 3.0, 4.0],
                  ],  # Can not be cast to array because of its shape
                  cast(
                      [[1, 2, 2, 3], [1.0, 2.0, 3.0, 4.0]], array_type
                  ),
                  sigma=2.0,
                  be=be,
              )
              np.testing.assert_allclose(
                  g,
                  np.array([[0.710595, 0.297229], [0.656297, 1.0]]),
                  atol=1e-5,
              )
              assert backend.belongs_to_backend(g)
  
              # soft-DTW
              d = tslearn.metrics.cdist_soft_dtw(
                  cast(
                      [[1, 2, 2, 3], [1.0, 2.0, 3.0, 4.0]], array_type
                  ),
                  gamma=0.01,
                  be=be,
              )
              np.testing.assert_allclose(
                  d, np.array([[-0.010986, 1.0], [1.0, 0.0]]), atol=1e-5
              )
              assert backend.belongs_to_backend(d)
  
              d = tslearn.metrics.cdist_soft_dtw(
                  cast(
                      [[1, 2, 2, 3], [1.0, 2.0, 3.0, 4.0]], array_type
                  ),
                  cast(
                      [[1, 2, 2, 3], [1.0, 2.0, 3.0, 4.0]], array_type
                  ),
                  gamma=0.01,
                  be=be,
              )
              np.testing.assert_allclose(
                  d, np.array([[-0.010986, 1.0], [1.0, 0.0]]), atol=1e-5
              )
              assert backend.belongs_to_backend(d)
  
              n, sz, d = 15, 10, 3
              rng = np.random.RandomState(0)
              time_series = rng.randn(n, sz, d)
              time_series = cast(time_series, array_type)
              dists = tslearn.metrics.cdist_soft_dtw_normalized(
                  time_series, be=be
              )
              assert backend.all(dists >= 0)
              assert backend.belongs_to_backend(dists)
  
              v1 = rng.randn(n, 1)
              v2 = rng.randn(n, 1)
              sqeuc = tslearn.metrics.SquaredEuclidean(
                  cast(np.array(v1.flat), array_type),
                  cast(np.array(v2.flat), array_type),
                  be=be,
              )
              c_dist = cdist(v1, v2, metric="sqeuclidean")
              sqeuc_compute = sqeuc.compute()
              np.testing.assert_allclose(
                  sqeuc_compute, c_dist, atol=1e-5
              )
              assert backend.belongs_to_backend(sqeuc_compute)
  
imports: import platform
  import sys
  import numpy
  import pytest
  import tslearn.clustering
  import tslearn.metrics
  from scipy.spatial.distance import cdist
  from tslearn.backend.backend import Backend, cast, instantiate_backend
  from tslearn.metrics.dtw_variants import dtw_path
  from tslearn.utils import to_time_series
label_desc: Use image node_id 11 for calling a global function with example usage: test_gak() without return types