class_docstr: Container for a translated sentence.
  
  Attributes:
      src (LongTensor): Source word IDs.
      srclen (List[int]): Source lengths.
      pred_sents (List[List[str]]): Words from the n-best translations.
      pred_scores (List[List[float]]): Log-probs of n-best translations.
      attns (List[FloatTensor]) : Attention distribution for each
          translation.
      gold_sent (List[str]): Words from gold translation.
      gold_score (List[float]): Log-prob of gold translation.
      word_aligns (List[FloatTensor]): Words Alignment distribution for
          each translation.
docstr: Log translation.
code: def log(self, sent_number, src_raw=""):
      """
      Log translation.
      """
  
      msg = ["\nSENT {}: {}\n".format(sent_number, src_raw)]
  
      best_pred = self.pred_sents[0]
      best_score = self.pred_scores[0]
      pred_sent = " ".join(best_pred)
      msg.append("PRED {}: {}\n".format(sent_number, pred_sent))
      msg.append("PRED SCORE: {:.4f}\n".format(best_score))
  
      if self.word_aligns is not None:
          pred_align = self.word_aligns[0]
          pred_align_pharaoh, _ = build_align_pharaoh(pred_align)
          pred_align_sent = " ".join(pred_align_pharaoh)
          msg.append("ALIGN: {}\n".format(pred_align_sent))
  
      if self.gold_sent is not None:
          tgt_sent = " ".join(self.gold_sent)
          msg.append("GOLD {}: {}\n".format(sent_number, tgt_sent))
          msg.append(("GOLD SCORE: {:.4f}\n".format(self.gold_score)))
      if len(self.pred_sents) > 1:
          msg.append("\nBEST HYP:\n")
          for score, sent in zip(self.pred_scores, self.pred_sents):
              msg.append("[{:.4f}] {}\n".format(score, sent))
  
      return "".join(msg)
  
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 Translation obj's underlying member method code with example usage: obj.log(sent_number, src_raw) and returns: str