code: def get_translation(nmt_outputs, sent_id, tgt_eos, subword_option):
      """Given batch decoding outputs, select a sentence and turn to text."""
      if tgt_eos:
          tgt_eos = tgt_eos.encode("utf-8")
      # Select a sentence
      output = nmt_outputs[sent_id, :].tolist()
  
      # If there is an eos symbol in outputs, cut them at that point.
      if tgt_eos and tgt_eos in output:
          output = output[: output.index(tgt_eos)]
  
      if subword_option == "bpe":  # BPE
          translation = utils.format_bpe_text(output)
      elif subword_option == "spm":  # SPM
          translation = utils.format_spm_text(output)
      else:
          translation = utils.format_text(output)
  
      return translation
  
file_path: nlp-architect/examples/sparse_gnmt/gnmt/utils/nmt_utils.py
imports: from __future__ import print_function
  import codecs
  import time
  import numpy
  import tensorflow
  from .None import misc_utils, evaluation_utils
label_desc: Use image node_id 2 for calling a global function with example usage: get_translation(nmt_outputs, sent_id, tgt_eos, subword_option) and returns: translation