code: def trace(backlinks, source_sents_lens, target_sents_lens):
      """
      Traverse the alignment cost from the tracebacks and retrieves
      appropriate sentence pairs.
  
      :param backlinks: A dictionary where the key is the alignment points and value is the cost (referencing the LanguageIndependent.PRIORS)
      :type backlinks: dict
      :param source_sents_lens: A list of target sentences' lengths
      :type source_sents_lens: list(int)
      :param target_sents_lens: A list of target sentences' lengths
      :type target_sents_lens: list(int)
      """
      links = []
      position = (len(source_sents_lens), len(target_sents_lens))
      while position != (0, 0) and all(p >= 0 for p in position):
          try:
              s, t = backlinks[position]
          except TypeError:
              position = (position[0] - 1, position[1] - 1)
              continue
          for i in range(s):
              for j in range(t):
                  links.append(
                      (position[0] - i - 1, position[1] - j - 1)
                  )
          position = (position[0] - s, position[1] - t)
  
      return links[::-1]
  
file_path: nltk/nltk/translate/gale_church.py
imports: import math
label_desc: Use image node_id 1 for calling a global function with example usage: trace(backlinks, source_sents_lens, target_sents_lens) and returns: links