class_docstr: Transformer encoder-decoder model.
      
class_docstr_tok: ["Transformer","encoder-decoder","model","."]
code: def forward(
      self,
      enc_input,
      enc_attn_mask,
      dec_input,
      dec_attn_mask,
      enc_layer_past=None,
      enc_get_key_value=False,
      enc_output=None,
      enc_output_attn_mask=None,
      dec_layer_past=None,
      dec_get_key_value=False,
      output_enc_hidden_only=False,
      enc_self_attention_relative_position_bias=None,
      dec_self_attention_relative_position_bias=None,
      dec_cross_attention_relative_position_bias=None,
      batch_data=None,
  ):
      # encoder
      if enc_output is None:
          if self.encoder is not None:
              enc_output = self.encode(
                  enc_input=enc_input,
                  enc_attn_mask=enc_attn_mask,
                  enc_layer_past=enc_layer_past,
                  enc_get_key_value=enc_get_key_value,
                  enc_self_attention_relative_position_bias=enc_self_attention_relative_position_bias,
                  batch_data=batch_data,
              )
          else:
              assert self.encoder_hidden_state is not None
              enc_output = self.encoder_hidden_state
      else:
          enc_attn_mask = enc_output_attn_mask.to(enc_attn_mask)
  
      if self.decoder is None or output_enc_hidden_only:
          return enc_output
  
      # decoder
      dec_output = self.decode(
          dec_input=dec_input,
          dec_attn_mask=dec_attn_mask,
          enc_output=enc_output[
              "enc_output"
          ]  # enc_output is a dict if we used hidden transformations
          if self.hiddens_module is not None
          else enc_output,
          # Adjust encoder attention mask if encoder is a perceiver.
          enc_attn_mask=self.get_hiddens_mask(enc_attn_mask),
          dec_layer_past=dec_layer_past,
          dec_get_key_value=dec_get_key_value,
          dec_self_attention_relative_position_bias=dec_self_attention_relative_position_bias,
          dec_cross_attention_relative_position_bias=dec_cross_attention_relative_position_bias,
      )
  
      # if self.hiddens_module is not None enc_output is a dict, else it is a torch.tensor
      return dec_output, enc_output
  
file_path: NeMo/nemo/collections/nlp/modules/common/megatron/megatron_encoder_decoder.py
imports: from ast import Mod
  import torch
  from nemo.collections.nlp.modules.common.megatron.hiddens import MegatronHiddensModule
  from nemo.collections.nlp.modules.common.megatron.megatron_perceiver_encoders import MegatronPerceiverEncoderModule
  from nemo.collections.nlp.modules.common.megatron.module import MegatronModule
  from nemo.collections.nlp.modules.common.megatron.utils import ApexGuardDefaults
label_desc: Use image node_id 5 for calling the MegatronTransformerEncoderDecoderModule obj's underlying member method code with example usage: obj.forward(enc_input, enc_attn_mask, dec_input, dec_attn_mask, enc_layer_past, enc_get_key_value, enc_output, enc_output_attn_mask, dec_layer_past, dec_get_key_value, output_enc_hidden_only, enc__attention_relative_position_bias, dec__attention_relative_position_bias, dec_cross_attention_relative_position_bias, batch_data) and returns: dec_output,  enc_output, enc_output