class_docstr: Output structure from Translator.
  
  sentence_id: Sentence id.
  translation: Translation string without sentence boundary tokens.
  tokens: List of translated tokens.
  score: Negative log probability of generated translation.
  pass_through_dict: Dictionary of key/value pairs to pass through when working with JSON.
  nbest_translations: List of nbest translations as strings.
  nbest_tokens: List of nbest translations as lists of tokens.
  nbest_scores: List of nbest scores, one for each nbest translation.
  factor_translations: List of factor outputs.
  factor_tokens: List of list of secondary factor tokens.
  factor_scores: List of secondary factor scores.
class_docstr_tok: ["Output","structure","from","Translator",".","sentence_id",":","Sentence","id",".","translation",":","Translation","string","without","sentence","boundary","tokens",".","tokens",":","List","of","translated","tokens",".","score",":","Negative","log","probability","of","generated","translation",".","pass_through_dict",":","Dictionary","of","key\/value","pairs","to","pass","through","when","working","with","JSON",".","nbest_translations",":","List","of","nbest","translations","as","strings",".","nbest_tokens",":","List","of","nbest","translations","as","lists","of","tokens",".","nbest_scores",":","List","of","nbest","scores",",","one","for","each","nbest","translation",".","factor_translations",":","List","of","factor","outputs",".","factor_tokens",":","List","of","list","of","secondary","factor","tokens",".","factor_scores",":","List","of","secondary","factor","scores","."]
docstr: Returns a dictionary suitable for json.dumps() representing all
  the information in the class. It is initialized with any keys
  present in the corresponding `TranslatorInput` object's pass_through_dict.
  Keys from here that are not overwritten by Sockeye will thus be passed
  through to the output.
  
  :return: A dictionary.
docstr_tok: ["Returns","a","dictionary","suitable","for","json.dumps","(",")","representing","all","the","information","in","the","class",".","It","is","initialized","with","any","keys","present","in","the","corresponding","`","TranslatorInput","`","object","'s","pass_through_dict",".","Keys","from","here","that","are","not","overwritten","by","Sockeye","will","thus","be","passed","through","to","the","output",".",":","return",":","A","dictionary","."]
code: def json(self) -> Dict:
      """
      Returns a dictionary suitable for json.dumps() representing all
      the information in the class. It is initialized with any keys
      present in the corresponding `TranslatorInput` object's pass_through_dict.
      Keys from here that are not overwritten by Sockeye will thus be passed
      through to the output.
  
      :return: A dictionary.
      """
      _d = (
          copy.deepcopy(self.pass_through_dict)
          if self.pass_through_dict is not None
          else {}
      )  # type: Dict[str, Any]
      _d["sentence_id"] = self.sentence_id
      _d["translation"] = self.translation
      _d["score"] = self.score
  
      if (
          self.nbest_translations is not None
          and len(self.nbest_translations) > 1
      ):
          _d["translations"] = self.nbest_translations
          _d["scores"] = self.nbest_scores
  
      if self.factor_translations is not None:
          for i, factor in enumerate(self.factor_translations, 1):
              _d[f"factor{i}"] = factor
  
      if self.factor_scores is not None:
          for i, score in enumerate(self.factor_scores, 1):
              _d[f"factor{i}_score"] = score
  
      if (
          self.nbest_factor_translations is not None
          and len(self.nbest_factor_translations) > 1
      ):
          _d["translations_factors"] = []
          for factor_translations in self.nbest_factor_translations:
              _d["translations_factors"].append(
                  {
                      f"factor{i}": factor_translation
                      for i, factor_translation in enumerate(
                          factor_translations, 1
                      )
                  }
              )
  
      return _d
  
imports: import copy
  import itertools
  import json
  import logging
  from dataclasses import dataclass
  from functools import partial
  from typing import Any, Callable, Dict, Generator, List, Optional, Set, Tuple, Union
  import numpy
  import torch
  from .None import constants
  from .None import lexicon
  from .None import utils
  from .None import vocab
  from .beam_search import CandidateScorer, get_search_algorithm, GreedySearch, SearchResult
  from .data_io import tokens2ids, get_prepended_token_length
  from .model import SockeyeModel
label_desc: Use image node_id 1 for calling the TranslatorOutput obj's underlying member method code with example usage: obj.json() and returns: _d