class_docstr: Transformer encoder-decoder model.
      
class_docstr_tok: ["Transformer","encoder-decoder","model","."]
docstr: Encodes embedder input using encoder
docstr_tok: ["Encodes","embedder","input","using","encoder"]
code: def encode(
      self,
      enc_input,
      enc_attn_mask,
      enc_layer_past=None,
      enc_get_key_value=False,
      enc_self_attention_relative_position_bias=None,
      batch_data=None,
  ):
      """Encodes embedder input using encoder"""
      if self.encoder is None:
          raise ValueError(
              f"Cannot call .encode(...) when self.encoder is None."
          )
      enc_output = self.encoder(
          enc_input=enc_input,
          enc_attn_mask=enc_attn_mask,
          layer_past=enc_layer_past,
          get_key_value=enc_get_key_value,
          enc_self_attention_relative_position_bias=enc_self_attention_relative_position_bias,
      )
  
      # apply hidden transformations if needed
      if self.hiddens_module is not None:
          enc_output = self.hiddens_module.apply_hidden_transforms(
              {
                  "hiddens": enc_output,
                  "hiddens_mask": self.get_hiddens_mask(enc_attn_mask),
              },
              batch_data=batch_data,
          )
  
      return 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 3 for calling the MegatronTransformerEncoderDecoderModule obj's underlying member method code with example usage: obj.encode(enc_input, enc_attn_mask, enc_layer_past, enc_get_key_value, enc__attention_relative_position_bias, batch_data) and returns: enc_output