docstr: Run the forward pass for an encoder-decoder model.
  
  First feed a batch of source tokens through the encoder. Then, feed the
  encoder output and previous decoder outputs (i.e., teacher forcing) to
  the decoder to produce the next outputs::
  
      encoder_out = self.encoder(src_tokens, src_lengths)
      return self.decoder(prev_output_tokens, encoder_out)
  
  Args:
      src_tokens (LongTensor): tokens in the source language of shape
          `(batch, src_len)`
      src_lengths (LongTensor): source sentence lengths of shape `(batch)`
      prev_output_tokens (LongTensor): previous decoder outputs of shape
          `(batch, tgt_len)`, for teacher forcing
      mode = 'sup_speech' or 'text'
  
  Returns:
      tuple:
          - the decoder's output of shape `(batch, tgt_len, vocab)`
          - a dictionary with any model-specific outputs
docstr_tok: ["Run","the","forward","pass","for","an","encoder-decoder","model",".","First","feed","a","batch","of","source","tokens","through","the","encoder",".","Then",",","feed","the","encoder","output","and","previous","decoder","outputs","(","i.e.",",","teacher","forcing",")","to","the","decoder","to","produce","the","next","outputs",":",":","encoder_out","=","self.encoder","(","src_tokens",",","src_lengths",")","return","self.decoder","(","prev_output_tokens",",","encoder_out",")","Args",":","src_tokens","(","LongTensor",")",":","tokens","in","the","source","language","of","shape","`","(","batch",",","src_len",")","`","src_lengths","(","LongTensor",")",":","source","sentence","lengths","of","shape","`","(","batch",")","`","prev_output_tokens","(","LongTensor",")",":","previous","decoder","outputs","of","shape","`","(","batch",",","tgt_len",")","`",",","for","teacher","forcing","mode","=","'sup_speech","'","or","'text'","Returns",":","tuple",":","-","the","decoder","'s","output","of","shape","`","(","batch",",","tgt_len",",","vocab",")","`","-","a","dictionary","with","any","model-specific","outputs"]
code: def forward(
      self,
      src_tokens,
      src_lengths,
      prev_output_tokens,
      use_encoder_outputs=False,
      src_txt_tokens=None,
      src_txt_lengths=None,
      mode="sup_speech",
      **kwargs,
  ):
      """
      Run the forward pass for an encoder-decoder model.
  
      First feed a batch of source tokens through the encoder. Then, feed the
      encoder output and previous decoder outputs (i.e., teacher forcing) to
      the decoder to produce the next outputs::
  
          encoder_out = self.encoder(src_tokens, src_lengths)
          return self.decoder(prev_output_tokens, encoder_out)
  
      Args:
          src_tokens (LongTensor): tokens in the source language of shape
              `(batch, src_len)`
          src_lengths (LongTensor): source sentence lengths of shape `(batch)`
          prev_output_tokens (LongTensor): previous decoder outputs of shape
              `(batch, tgt_len)`, for teacher forcing
          mode = 'sup_speech' or 'text'
  
      Returns:
          tuple:
              - the decoder's output of shape `(batch, tgt_len, vocab)`
              - a dictionary with any model-specific outputs
      """
      if mode == "text":
          assert src_txt_tokens is None
          src_txt_tokens = src_tokens
          src_txt_lengths = src_lengths
          src_tokens = None
          src_lengths = None
      encoder_out = self.encoder(
          src_tokens,
          src_lengths=src_lengths,
          src_txt_tokens=src_txt_tokens,
          src_txt_lengths=src_txt_lengths,
          **kwargs,
      )
      has_txt_input = True if src_txt_tokens is not None else False
      decoder_out = self.decoder(
          prev_output_tokens,
          encoder_out=encoder_out,
          has_txt_input=has_txt_input,
          **kwargs,
      )
      if use_encoder_outputs:
          return decoder_out, encoder_out
      return decoder_out
  
imports: import logging
  from collections import namedtuple
  import torch
  import torch.nn
  from fairseq import checkpoint_utils
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqDecoder, FairseqEncoderDecoderModel, register_model, register_model_architecture
  from fairseq.models.fairseq_encoder import EncoderOut
  from fairseq.models.speech_to_text import TransformerDecoder, S2TTransformerEncoder
  from fairseq.models.transformer import TransformerEncoder
  from fairseq.modules import TransformerEncoderLayer, GradMultiply, LayerNorm
label_desc: Use image node_id 9 for calling the DualInputS2TTransformerModel obj's underlying member method code with example usage: obj.forward(src_tokens, src_lengths, prev_output_tokens, use_encoder_outputs, src_txt_tokens, src_txt_lengths, mode) and returns: decoder_out, decoder_out,  encoder_out