code: def _njit_gak(gram):
      """Compute Global Alignment Kernel (GAK) between (possibly
      multidimensional) time series and return it.
  
      Parameters
      ----------
      gram : array-like, shape=(sz1, sz2)
          Gram matrix.
  
      Returns
      -------
      float
          Kernel value
      """
      sz1, sz2 = gram.shape
  
      cum_sum = np.zeros((sz1 + 1, sz2 + 1))
      cum_sum[0, 0] = 1.0
  
      for i in range(sz1):
          for j in range(sz2):
              cum_sum[i + 1, j + 1] = (
                  cum_sum[i, j + 1] + cum_sum[i + 1, j] + cum_sum[i, j]
              ) * gram[i, j]
  
      return cum_sum[sz1, sz2]
  
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 2 for calling a global function with example usage: _njit_gak(gram) and returns: cum_sum