code: def __rqa_backtrack(score, pointers):
      """RQA path backtracking
  
      Given the score matrix and backtracking index array,
      reconstruct the optimal path.
      """
      # backtracking rubric:
      #   0 ==> diagonal move
      #   1 ==> knight move up
      #   2 ==> knight move left
      #  -1 ==> reset (sim = 0)
      #  -2 ==> start of sequence (sim > 0)
  
      # This array maps the backtracking values to the
      # relative index offsets
      offsets = [(-1, -1), (-1, -2), (-2, -1)]
  
      # Find the maximum to end the path
      idx = list(np.unravel_index(np.argmax(score), score.shape))
  
      # Construct the path
      path: List = []
      while True:
          bt_index = pointers[tuple(idx)]
  
          # A -1 indicates a non-inclusive reset
          # this can only happen when sim[idx] == 0,
          # and a reset with zero score should not be included
          # in the path.  In this case, we're done.
          if bt_index == -1:
              break
  
          # Other bt_index values are okay for inclusion
          path.insert(0, idx)
  
          # -2 indicates beginning of sequence,
          # so we can't backtrack any further
          if bt_index == -2:
              break
  
          # Otherwise, prepend this index and continue
          idx = [idx[_] + offsets[bt_index][_] for _ in range(len(idx))]
  
      # If there's no alignment path at all, eg an empty cross-similarity
      # matrix, return a properly shaped and typed array
      if not path:
          return np.empty((0, 2), dtype=np.uint)
  
      return np.asarray(path, dtype=np.uint)
  
imports: from __future__ import annotations
  import numpy
  from scipy.spatial.distance import cdist
  from numba import jit
  from .util import pad_center, fill_off_diagonal, is_positive_int, tiny, expand_to
  from .util.exceptions import ParameterError
  from .filters import get_window
  from typing import Any, Iterable, List, Optional, Tuple, Union, overload
  from typing_extensions import Literal
  from ._typing import _WindowSpec, _IntLike_co
label_desc: Use image node_id 18 for calling a global function with example usage: __rqa_backtrack(score, pointers) and returns: np, np