class_docstr: A wrapper around an ensemble of models.
class_docstr_tok: ["A","wrapper","around","an","ensemble","of","models","."]
code: def forward_decoder(
      self,
      decoder_out,
      encoder_outs,
      eos_penalty=0.0,
      max_ratio=None,
      **kwargs,
  ):
      # LevT ensembling
      # A pipeline of three steps: deletion, placeholder, and word insertion.
      # We need to average scores in each step in a pipeline way because of dependence.
      # deletion
      output_tokens = decoder_out.output_tokens
      output_scores = decoder_out.output_scores
      attn = decoder_out.attn
  
      bsz = output_tokens.size(0)
      if max_ratio is None:
          max_lens = output_tokens.new().fill_(255)
      else:
          if not encoder_outs[0]["encoder_padding_mask"]:
              src_lens = (
                  encoder_outs[0]["encoder_out"][0]
                  .new(bsz)
                  .fill_(encoder_outs[0]["encoder_out"][0].size(1))
              )
          else:
              src_lens = (
                  ~encoder_outs[0]["encoder_padding_mask"][0]
              ).sum(1)
          max_lens = (src_lens * max_ratio).clamp(min=10).long()
  
      # delete words
      # do not delete tokens if it is <s> </s>
      can_del_word = output_tokens.ne(self.pad).sum(1) > 2
      if can_del_word.sum() != 0:  # we cannot delete, skip
          output_tokens, output_scores, attn = self.forward_word_del(
              encoder_outs,
              output_tokens,
              output_scores,
              attn,
              can_del_word,
          )
  
      # insert placeholders
      can_ins_mask = output_tokens.ne(self.pad).sum(1) < max_lens
      if can_ins_mask.sum() != 0:
          output_tokens, output_scores = self.forward_mask_ins(
              encoder_outs,
              output_tokens,
              output_scores,
              can_ins_mask,
              eos_penalty,
              max_lens,
          )
  
      # insert words
      can_ins_word = output_tokens.eq(self.unk).sum(1) > 0
      if can_ins_word.sum() != 0:
          output_tokens, output_scores, attn = self.forward_word_ins(
              encoder_outs,
              output_tokens,
              output_scores,
              attn,
              can_ins_word,
          )
  
      # delete some unnecessary paddings
      cut_off = output_tokens.ne(self.pad).sum(1).max()
      output_tokens = output_tokens[:, :cut_off]
      output_scores = output_scores[:, :cut_off]
      attn = None if attn is None else attn[:, :cut_off, :]
      return decoder_out._replace(
          output_tokens=output_tokens,
          output_scores=output_scores,
          attn=attn,
          history=None,
      )
  
imports: import math
  import torch
  import torch.nn.functional
  from fairseq.models.nat import _apply_del_words, _apply_ins_masks, _apply_ins_words, _fill, _skip, _skip_encoder_out
label_desc: Use image node_id 2 for calling the EnsembleLevT obj's underlying member method code with example usage: obj.forward_decoder(decoder_out, encoder_outs, eos_penalty, max_ratio) and returns: decoder_out