code: def _gak_gram(s1, s2, sigma=1.0, be=None):
      """Compute Global Alignment Kernel (GAK) Gram matrix between (possibly
      multidimensional) time series and return it.
  
      Parameters
      ----------
      s1 : array-like, shape=(sz1, d)
          A time series.
      s2 : array-like, shape=(sz2, d)
          Another time series.
      sigma : float (default 1.)
          Bandwidth of the internal gaussian kernel used for GAK.
      be : Backend object or string or None
          Backend. If `be` is an instance of the class `NumPyBackend` or the string `"numpy"`,
          the NumPy backend is used.
          If `be` is an instance of the class `PyTorchBackend` or the string `"pytorch"`,
          the PyTorch backend is used.
          If `be` is `None`, the backend is determined by the input arrays.
          See our :ref:`dedicated user-guide page <backend>` for more information.
  
      Returns
      -------
      gram : array-like, shape=(sz1, sz2)
          Gram matrix.
      """
      be = instantiate_backend(be, s1)
      gram = -be.cdist(s1, s2, "sqeuclidean") / (2 * sigma**2)
      gram = be.array(gram)
      gram -= be.log(2 - be.exp(gram))
      return be.exp(gram)
  
imports: import numpy
  from joblib import Parallel, delayed
  from numba import njit
  from sklearn.utils import check_random_state
  from tslearn.backend import instantiate_backend
  from tslearn.utils import check_equal_size, to_time_series, to_time_series_dataset, ts_size
  from .dtw_variants import dtw, dtw_path
  from .soft_dtw_fast import _jacobian_product_sq_euc, _njit_jacobian_product_sq_euc, _njit_soft_dtw, _njit_soft_dtw_grad, _soft_dtw, _soft_dtw_grad
  from .utils import _cdist_generic
label_desc: Use image node_id 3 for calling a global function with example usage: _gak_gram(s1, s2, sigma, be) and returns: be