class_docstr: Build a word-based translation from the batch output
  of translator and the underlying dictionaries.
  
  Replacement based on "Addressing the Rare Word
  Problem in Neural Machine Translation" :cite:`Luong2015b`
  
  Args:
     data ():
     vocabs ():
     n_best (int): number of translations produced
     replace_unk (bool): replace unknown words using attention
code: def _build_target_tokens(self, src, srclen, pred, attn, voc, dyn_voc):
      if dyn_voc is None:
          tokens = [voc[tok] for tok in pred.tolist()]
      else:
          tokens = [
              voc[tok]
              if tok < len(voc)
              else dyn_voc.ids_to_tokens[
                  tok - len(self.vocabs["src"].ids_to_tokens)
              ]
              for tok in pred.tolist()
          ]
      if tokens[-1] == DefaultTokens.EOS:
          tokens = tokens[:-1]
  
      if self.replace_unk and attn is not None and src is not None:
          for i in range(len(tokens)):
              if tokens[i] == DefaultTokens.UNK:
                  _, max_index = attn[i][:srclen].max(0)
                  src_tok = self.vocabs["src"].ids_to_tokens[
                      src[max_index.item()]
                  ]
                  tokens[i] = src_tok
                  if self.phrase_table_dict:
                      if src_tok in self.phrase_table_dict:
                          tokens[i] = self.phrase_table_dict[src_tok]
      return tokens
  
file_path: OpenNMT-py/onmt/translate/translation.py
imports: import os
  from onmt.constants import DefaultTokens
  from onmt.utils.alignment import build_align_pharaoh
label_desc: Use image node_id 2 for calling the TranslationBuilder obj's underlying member method code with example usage: obj._build_target_tokens(src, srclen, pred, attn, voc, dyn_voc) and returns: tokens