class_docstr: Implements a Luna Encoder Layer used in masked pre-trained language models
  and fine-tuned classication/regression mdoel
class_docstr_tok: ["Implements","a","Luna","Encoder","Layer","used","in","masked","pre-trained","language","models","and","fine-tuned","classication\/regression","mdoel"]
docstr: LayerNorm is applied either before or after the self-attention/ffn
  modules similar to the original Transformer implementation.
docstr_tok: ["LayerNorm","is","applied","either","before","or","after","the","self-attention\/ffn","modules","similar","to","the","original","Transformer","implementation","."]
code: def forward(
      self,
      x: torch.Tensor,
      px: torch.Tensor,
      x_padding_mask: Optional[torch.Tensor] = None,
      px_padding_mask: Optional[torch.Tensor] = None,
  ):
      """
      LayerNorm is applied either before or after the self-attention/ffn
      modules similar to the original Transformer implementation.
      """
      residual = x
      presidual = px
      # apply prev layer norm
      if self.normalize_before:
          x = self.self_attn_layer_norm(x)
          px = self.self_atten_proj_layer_norm(px)
  
      x, px, attn = self.self_attn(
          query=x,
          pquery=px,
          context=x,
          context_padding_mask=x_padding_mask,
          pcontext_padding_mask=px_padding_mask,
          need_weights=False,
      )
      # apply dropout
      x = self.dropout_module(x)
      px = self.dropout_module(px)
      # residual
      x = residual + x
      px = presidual + px
  
      # apply post layer norm
      if not self.normalize_before:
          x = self.self_attn_layer_norm(x)
          px = self.self_atten_proj_layer_norm(px)
  
      #######################################################################
      # Feed-Forward Network
      residual = x
      # apply prev layer norm
      if self.normalize_before:
          x = self.final_layer_norm(x)
  
      x = self.activation_fn(self.fc1(x))
      x = self.activation_dropout_module(x)
      x = self.fc2(x)
      x = self.dropout_module(x)
      x = residual + x
  
      # apply post layer norm
      if not self.normalize_before:
          x = self.final_layer_norm(x)
      return x, px, attn
  
imports: import math
  from typing import Callable, Optional
  import torch
  from fairseq import utils
  from fairseq.modules import LayerDropModuleList, LayerNorm, PositionalEmbedding
  from fairseq.modules.fairseq_dropout import FairseqDropout
  from pytext.utils.usage import log_class_usage
  from torch import nn
  from torch.nn import Parameter
  from .None import LunarMultiheadAttention
label_desc: Use image node_id 5 for calling the LunaSentenceEncoderLayer obj's underlying member method code with example usage: obj.forward(x, px, x_padding_mask, px_padding_mask) and returns: x,  px,  attn