class_docstr: Transformer encoder model.
      
class_docstr_tok: ["Transformer","encoder","model","."]
code: def forward(
      self,
      enc_input,
      enc_attn_mask,
      layer_past=None,
      get_key_value=False,
      enc_self_attention_relative_position_bias=None,
  ):
      if enc_self_attention_relative_position_bias is not None:
          raise ValueError(
              f"enc_self_attention_relative_position_bias is not supported for Megatron Perceiver Encoders."
          )
  
      # convert to Megatron mask
      latent_attention_mask = torch.ones(
          enc_input.size(1), self.hidden_steps
      ).to(enc_input.device)
  
      # First convert from 2D (B x T) to 3D (B x T x T)
      # Next convert to 4D (B x 1 x T x T) - unsqueeze(1) is for the head dim.
      latent_attention_mask_4d = attn_mask_postprocess(
          build_attention_mask_3d(
              source_mask=latent_attention_mask,
              target_mask=latent_attention_mask,
              attn_mask_type=AttnMaskType.padding,
          )
      )
      enc_dec_attn_mask_4d = attn_mask_postprocess(
          build_attention_mask_3d(
              source_mask=latent_attention_mask,
              target_mask=enc_attn_mask,
              attn_mask_type=AttnMaskType.padding,
          )
      )
  
      # 1. Expand latent hidden states to B x S_perceiver x H
      # 2. Transpose to S_perceiver x B x H
      hidden_states = (
          self.init_hidden.unsqueeze(0)
          .expand(enc_input.size(1), -1, -1)
          .transpose(1, 0)
      )
      for i in range(self.num_layers):
          residual = hidden_states
          hidden_states = self.cross_attn_layers[i](
              hidden_states=hidden_states,
              attention_mask=latent_attention_mask_4d,
              enc_dec_attn_mask=enc_dec_attn_mask_4d,
              encoder_output=enc_input,
          )
          for j in range(self.num_self_attention_per_cross_attention):
              hidden_states = self.self_attn_layers[
                  i * self.num_self_attention_per_cross_attention + j
              ](
                  hidden_states=hidden_states,
                  attention_mask=latent_attention_mask_4d,
              )
  
          hidden_states += residual
  
      return self.final_layernorm(hidden_states)
  
file_path: NeMo/nemo/collections/nlp/modules/common/megatron/megatron_perceiver_encoders.py
imports: import torch
  from nemo.collections.nlp.modules.common.megatron.fused_layer_norm import get_layer_norm
  from nemo.collections.nlp.modules.common.megatron.layer_type import LayerType
  from nemo.collections.nlp.modules.common.megatron.module import MegatronModule
  from nemo.collections.nlp.modules.common.megatron.transformer import ParallelTransformer
  from nemo.collections.nlp.modules.common.megatron.utils import ApexGuardDefaults, attn_mask_postprocess, build_attention_mask_3d
label_desc: Use image node_id 5 for calling the MegatronPerceiverEncoderModule obj's underlying member method code with example usage: obj.forward(enc_input, enc_attn_mask, layer_past, get_key_value, enc__attention_relative_position_bias) and returns: self