code: def _soft_dtw_grad(D, R, E, gamma, be=None):
      """Compute gradient of soft-DTW w.r.t. D.
  
      Parameters
      ----------
      D : array-like, shape=(m, n), dtype=float64
      R : array-like, shape=(m+2, n+2), dtype=float64
      E : array-like, shape=(m+2, n+2), dtype=float64
      gamma : float64
          Regularization parameter.
      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.
      """
      be = instantiate_backend(be, D, R, E)
  
      m = D.shape[0] - 1
      n = D.shape[1] - 1
  
      # Initialization.
      D[:m, n] = 0
      D[m, :n] = 0
      R[1 : m + 1, n + 1] = -be.dbl_max
      R[m + 1, 1 : n + 1] = -be.dbl_max
  
      E[m + 1, n + 1] = 1
      R[m + 1, n + 1] = R[m, n]
      D[m, n] = 0
  
      for j in range(n, 0, -1):  # ranges from n to 1
          for i in range(m, 0, -1):  # ranges from m to 1
              a = be.exp((R[i + 1, j] - R[i, j] - D[i, j - 1]) / gamma)
              b = be.exp((R[i, j + 1] - R[i, j] - D[i - 1, j]) / gamma)
              c = be.exp((R[i + 1, j + 1] - R[i, j] - D[i, j]) / gamma)
              E[i, j] = (
                  E[i + 1, j] * a
                  + E[i, j + 1] * b
                  + E[i + 1, j + 1] * c
              )
  
file_path: tslearn/tslearn/metrics/soft_dtw_fast.py
imports: import numpy
  from numba import njit, prange
  from tslearn.backend.backend import instantiate_backend
label_desc: Use image node_id 8 for calling a global function with example usage: _soft_dtw_grad(D, R, E, gamma, be) without return types