class_docstr: Initialize the Lightseq Transformer Encoder Layer.
  
  Static variable:
      layer_id: The layer-index counter starting from 0 and incrementing by 1 every time a layer object is instantiated,
      e.g. if a model has 24 transformer layers, layer_id goes from 0 to 23.
  Arguments:
      config: An object of LSTransformerEncoderLayer config, see get_config
  
      initial_weights: Optional: Only used for unit test
  
      initial_biases: Optional: Only used for unit test
class_docstr_tok: ["Initialize","the","Lightseq","Transformer","Encoder","Layer",".","Static","variable",":","layer_id",":","The","layer-index","counter","starting","from","0","and","incrementing","by","1","every","time","a","layer","object","is","instantiated",",","e.g",".","if","a","model","has","24","transformer","layers",",","layer_id","goes","from","0","to","23",".","Arguments",":","config",":","An","object","of","LSTransformerEncoderLayer","config",",","see","get_config","initial_weights",":","Optional",":","Only","used","for","unit","test","initial_biases",":","Optional",":","Only","used","for","unit","test"]
code: def forward(self, hidden_states, encoder_padding_mask, **kwargs):
      # encoder_padding_mask is a mask for the input sequence
      # sizes are [batch_size, seq_len] or [seq_len] when batch_size = 1
      # masked value should be 1.0, unmasked value should be 0.0
  
      self.config.training = self.training
      self.config.is_grad_enabled = torch.is_grad_enabled()
      self.config.quant_mode = self.quant_mode
  
      hidden_states = hidden_states.contiguous()
      encoder_padding_mask = (
          (encoder_padding_mask * -1e8)
          .type_as(hidden_states)
          .contiguous()
      )
      if self.config.fp16 and self.para.dtype != torch.half:
          if hasattr(self, "para_16"):
              self.para_16.copy_(self.para.to(torch.half))
          else:
              self.register_buffer(
                  "para_16", self.para.clone().detach().half()
              )
  
      self.__assign_layer_weight_grad()
      bs, sl, dim = hidden_states.size()
      if bs * sl > self.config.max_batch_tokens:
          raise ValueError(
              f"Batch token numbers {bs * sl} exceeds the limit"
              f" {self.config.max_batch_tokens}."
          )
      if sl > self.config.max_seq_len:
          raise ValueError(
              f"Sequence length {sl} exceeds the limit {self.config.max_seq_len}."
          )
      if len(encoder_padding_mask.size()) == 1:
          assert bs == 1 and sl == encoder_padding_mask.size(0)
      else:
          assert bs == encoder_padding_mask.size(
              0
          ) and sl == encoder_padding_mask.size(1)
      output = LSTransformerEncoderFunc.apply(
          hidden_states,
          encoder_padding_mask,
          self.para,
          self.config,
      )
  
      return output.to(self.para)
  
imports: from itertools import zip_longest
  import math
  import copy
  import torch
  from torch import nn
  from torch.autograd import Function
  from lightseq.training.ops.pytorch.layer_base import TransformerEncoderLayerBase
  from lightseq.training.ops.pytorch.builder import TransformerBuilder
  from lightseq.training.ops.pytorch.quantization import weight_quant_config, act_quant_config, relu_quant_config
  from lightseq.training.ops.pytorch.util import copy_para, state_dict, calc_offset
label_desc: Use image node_id 10 for calling the LSTransformerEncoderLayer obj's underlying member method code with example usage: obj.forward(hidden_states, encoder_padding_mask) and returns: output