docstr: Beam Search sequence generator based on the decoder followed by log_softmax
  with external language model fusion.
  Args:
      *all args of BeamSearchSequenceGenerator class
      language_model: nemo TransformerLMModel
      fusion_coef: coefficient before language model score, the resulting score is
          score = log P_NMT(y|x) + fusion_coef * log P_LM(y)
  Kwargs:
      all remaining parameters of GreedySequenceGenerator class
docstr_tok: ["Beam","Search","sequence","generator","based","on","the","decoder","followed","by","log_softmax","with","external","language","model","fusion",".","Args",":","*","all","args","of","BeamSearchSequenceGenerator","class","language_model",":","nemo","TransformerLMModel","fusion_coef",":","coefficient","before","language","model","score",",","the","resulting","score","is","score","=","log","P_NMT","(","y|x",")","+","fusion_coef","*","log","P_LM","(","y",")","Kwargs",":","all","remaining","parameters","of","GreedySequenceGenerator","class"]
code: def __init__(
      self,
      embedding,
      decoder,
      log_softmax,
      language_model,
      beam_size=1,
      len_pen=0,
      fusion_coef=0.0,
      **kwargs,
  ):
      """
      Beam Search sequence generator based on the decoder followed by log_softmax
      with external language model fusion.
      Args:
          *all args of BeamSearchSequenceGenerator class
          language_model: nemo TransformerLMModel
          fusion_coef: coefficient before language model score, the resulting score is
              score = log P_NMT(y|x) + fusion_coef * log P_LM(y)
      Kwargs:
          all remaining parameters of GreedySequenceGenerator class
      """
  
      super().__init__(embedding, decoder, log_softmax, **kwargs)
      self.language_model = language_model
      self.beam_size = beam_size
      self.len_pen = len_pen
      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 BeamSearchSequenceGeneratorWithLanguageModel object from inherited base classes: GreedySequenceGenerator with example: obj = BeamSearchSequenceGeneratorWithLanguageModel(embedding, decoder, log_softmax, language_model, beam_size, len_pen, fusion_coef)