code: def subsequence_path(acc_cost_mat, idx_path_end, be=None):
      r"""Compute the optimal path through an accumulated cost matrix given the
      endpoint of the sequence.
  
      Parameters
      ----------
      acc_cost_mat: array-like, shape=(sz1, sz2)
          Accumulated cost matrix comparing subsequence from a longer sequence.
      idx_path_end: int
          The end position of the matched subsequence in the longer sequence.
      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
      -------
      path: list of tuples of integer pairs
          Matching path represented as a list of index pairs. In each pair, the
          first index corresponds to `subseq` and the second one corresponds to
          `longseq`. The startpoint of the Path is :math:`P_0 = (0, ?)` and it
          ends at :math:`P_L = (len(subseq)-1, idx\_path\_end)`
  
      Examples
      --------
  
      >>> acc_cost_mat = numpy.array([[1., 0., 0., 1., 4.],
      ...                             [5., 1., 1., 0., 1.]])
      >>> # calculate the globally optimal path
      >>> optimal_end_point = numpy.argmin(acc_cost_mat[-1, :])
      >>> path = subsequence_path(acc_cost_mat, optimal_end_point)
      >>> path
      [(0, 2), (1, 3)]
  
      See Also
      --------
      dtw_subsequence_path : Get the similarity score for DTW
      subsequence_cost_matrix: Calculate the required cost matrix
  
      """
      be = instantiate_backend(be, acc_cost_mat)
      acc_cost_mat = be.array(acc_cost_mat)
      if be.is_numpy:
          return _njit_subsequence_path(acc_cost_mat, idx_path_end)
      return _subsequence_path(acc_cost_mat, idx_path_end, be=be)
  
imports: import warnings
  import numpy
  from numba import njit, prange
  from tslearn.backend import instantiate_backend
  from tslearn.utils import to_time_series
  from .utils import _cdist_generic
label_desc: Use image node_id 24 for calling a global function with example usage: subsequence_path(acc_cost_mat, idx_path_end, be) and returns: _subsequence_path, _njit_subsequence_path