docstr: Generates translations from multiple source sentences
  
  This only supports one model for now.
  
  Args:
      models: List of FairseqModel objects. Each one must implement
          expand_encoder_output() method to replicate encoder outputs.
          For now only one model is supported
      min/maxlen: The length of the generated output will be bounded by
          minlen and maxlen (not including the end-of-sentence marker).
      stop_early: Stop generation immediately after we finalize beam_size
          hypotheses, even though longer hypotheses might have better
          normalized scores.
      normalize_scores: Normalize scores by the length of the output.
      word_reward: add this value to score each token except EOS
          (an alternative method to len_penalty for encouraging longer
          output)
      model_weights: None or list of Python floats of the same length as
          `models` with ensemble interpolation weights.
      use_char_source: if True, encoder inputs consist of (src_tokens,
          src_lengths, char_inds, word_lengths)
docstr_tok: ["Generates","translations","from","multiple","source","sentences","This","only","supports","one","model","for","now",".","Args",":","models",":","List","of","FairseqModel","objects",".","Each","one","must","implement","expand_encoder_output","(",")","method","to","replicate","encoder","outputs",".","For","now","only","one","model","is","supported","min\/maxlen",":","The","length","of","the","generated","output","will","be","bounded","by","minlen","and","maxlen","(","not","including","the","end-of-sentence","marker",")",".","stop_early",":","Stop","generation","immediately","after","we","finalize","beam_size","hypotheses",",","even","though","longer","hypotheses","might","have","better","normalized","scores",".","normalize_scores",":","Normalize","scores","by","the","length","of","the","output",".","word_reward",":","add","this","value","to","score","each","token","except","EOS","(","an","alternative","method","to","len_penalty","for","encouraging","longer","output",")","model_weights",":","None","or","list","of","Python","floats","of","the","same","length","as","`","models","`","with","ensemble","interpolation","weights",".","use_char_source",":","if","True",",","encoder","inputs","consist","of","(","src_tokens",",","src_lengths",",","char_inds",",","word_lengths",")"]
code: def __init__(
      self,
      models,
      tgt_dict,
      beam_size=1,
      minlen=1,
      maxlen=None,
      stop_early=True,
      normalize_scores=True,
      len_penalty=0,
      unk_reward=0,
      lexicon_reward=0,
      retain_dropout=False,
      word_reward=0,
      model_weights=None,
      use_char_source=False,
      align_to=1,
  ):
      """Generates translations from multiple source sentences
  
      This only supports one model for now.
  
      Args:
          models: List of FairseqModel objects. Each one must implement
              expand_encoder_output() method to replicate encoder outputs.
              For now only one model is supported
          min/maxlen: The length of the generated output will be bounded by
              minlen and maxlen (not including the end-of-sentence marker).
          stop_early: Stop generation immediately after we finalize beam_size
              hypotheses, even though longer hypotheses might have better
              normalized scores.
          normalize_scores: Normalize scores by the length of the output.
          word_reward: add this value to score each token except EOS
              (an alternative method to len_penalty for encouraging longer
              output)
          model_weights: None or list of Python floats of the same length as
              `models` with ensemble interpolation weights.
          use_char_source: if True, encoder inputs consist of (src_tokens,
              src_lengths, char_inds, word_lengths)
      """
      self.models = models
      self.pad = tgt_dict.pad()
      self.unk = tgt_dict.unk()
      self.eos = tgt_dict.eos()
      self.vocab_size = len(tgt_dict)
      self.beam_size = beam_size
      self.minlen = minlen
      max_decoder_len = min(
          m.max_decoder_positions() for m in self.models
      )
      self.maxlen = (
          max_decoder_len
          if maxlen is None
          else min(maxlen, max_decoder_len)
      )
      self.stop_early = stop_early
      self.normalize_scores = normalize_scores
      self.len_penalty = len_penalty
      self.unk_reward = unk_reward
      self.lexicon_reward = lexicon_reward
      self.lexicon_indices = tgt_dict.lexicon_indices_list()
      self.retain_dropout = retain_dropout
      self.word_reward = word_reward
      if model_weights is not None:
          assert len(models) == len(model_weights)
          self.model_weights = model_weights
      else:
          self.model_weights = [1.0 / len(models)] * len(models)
      self.use_char_source = use_char_source
  
file_path: translate/pytorch_translate/research/multisource/multisource_decode.py
imports: import math
  import torch
  from fairseq import utils
  from fairseq.models import FairseqIncrementalDecoder
label_desc: Use image node_id 1 to create a new MultiSourceSequenceGenerator object from inherited base classes: torch.nn with example: obj = MultiSourceSequenceGenerator(models, tgt_dict, beam_size, minlen, maxlen, stop_early, normalize_scores, len_penalty, unk_reward, lexicon_reward, retain_dropout, word_reward, model_weights, use_char_source, align_to)