docstr: Ensemble Beam Search sequence generator based on the decoder followed by
  log_softmax. Averages the probabilities of different models.
  NOTE: All models must have been trained with the same BPE tokenizers.
  
  Args:
      encoders: A list of encoders
      embeddings: A list of decoder embedding layers
      decoders: A list of decoders
      log_softmaxes: A list of decoder output layers
      beam_size: Beam size
      len_pen: Length penalty to adjust logprob scores to favor longer sequences
      pad: pad id
      bos: beginning of sequence id
      eos: end of sequence id
      max_sequence_length: maximum sequence length
      max_delta_length: maximum length difference between input and output
      batch_size: batch size if not inferrable from input sequence
docstr_tok: ["Ensemble","Beam","Search","sequence","generator","based","on","the","decoder","followed","by","log_softmax",".","Averages","the","probabilities","of","different","models",".","NOTE",":","All","models","must","have","been","trained","with","the","same","BPE","tokenizers",".","Args",":","encoders",":","A","list","of","encoders","embeddings",":","A","list","of","decoder","embedding","layers","decoders",":","A","list","of","decoders","log_softmaxes",":","A","list","of","decoder","output","layers","beam_size",":","Beam","size","len_pen",":","Length","penalty","to","adjust","logprob","scores","to","favor","longer","sequences","pad",":","pad","id","bos",":","beginning","of","sequence","id","eos",":","end","of","sequence","id","max_sequence_length",":","maximum","sequence","length","max_delta_length",":","maximum","length","difference","between","input","and","output","batch_size",":","batch","size","if","not","inferrable","from","input","sequence"]
code: def __init__(
      self,
      encoders,
      embeddings,
      decoders,
      log_softmaxes,
      beam_size=1,
      len_pen=0,
      pad=0,
      bos=1,
      eos=2,
      max_sequence_length=512,
      max_delta_length=20,
      batch_size=1,
      language_model=None,
      fusion_coef=None,
  ):
      """
      Ensemble Beam Search sequence generator based on the decoder followed by
      log_softmax. Averages the probabilities of different models.
      NOTE: All models must have been trained with the same BPE tokenizers.
  
      Args:
          encoders: A list of encoders
          embeddings: A list of decoder embedding layers
          decoders: A list of decoders
          log_softmaxes: A list of decoder output layers
          beam_size: Beam size
          len_pen: Length penalty to adjust logprob scores to favor longer sequences
          pad: pad id
          bos: beginning of sequence id
          eos: end of sequence id
          max_sequence_length: maximum sequence length
          max_delta_length: maximum length difference between input and output
          batch_size: batch size if not inferrable from input sequence
      """
      self.encoders = encoders
      self.embeddings = embeddings
      self.decoders = decoders
      self.log_softmaxes = log_softmaxes
      self.beam_size = beam_size
      self.len_pen = len_pen
      self.pad, self.bos, self.eos = pad, bos, eos
      self.max_seq_length = max_sequence_length
      self.max_delta_len = max_delta_length
      self.batch_size = batch_size
      assert (
          len(embeddings)
          == len(decoders)
          == len(log_softmaxes)
          == len(encoders)
      )
      self.num_models = len(encoders)
      self.language_model = language_model
      self.fusion_coef = fusion_coef
  
imports: from contextlib import contextmanager
  import torch
  from nemo.collections.common.parts import NEG_INF, mask_padded_tokens
label_desc: Use image node_id 1 to create a new EnsembleBeamSearchSequenceGenerator object  with example: obj = EnsembleBeamSearchSequenceGenerator(encoders, embeddings, decoders, log_softmaxes, beam_size, len_pen, pad, bos, eos, max_sequence_length, max_delta_length, batch_size, language_model, fusion_coef)