class_docstr: One TransformerEncoder consists of several TransformerLayers.
  
  - n_layers(num): num of transformer layers in transformer encoder. Default: 2
  - n_heads(num): num of attention heads for multi-head attention layer. Default: 2
  - hidden_size(num): the input and output hidden size. Default: 64
  - inner_size(num): the dimensionality in feed-forward layer. Default: 256
  - hidden_dropout_prob(float): probability of an element to be zeroed. Default: 0.5
  - attn_dropout_prob(float): probability of an attention score to be zeroed. Default: 0.5
  - hidden_act(str): activation function in feed-forward layer. Default: 'gelu'
                candidates: 'gelu', 'relu', 'swish', 'tanh', 'sigmoid'
  - layer_norm_eps(float): a value added to the denominator for numerical stability. Default: 1e-12
class_docstr_tok: ["One","TransformerEncoder","consists","of","several","TransformerLayers",".","-","n_layers","(","num",")",":","num","of","transformer","layers","in","transformer","encoder",".","Default",":","2","-","n_heads","(","num",")",":","num","of","attention","heads","for","multi-head","attention","layer",".","Default",":","2","-","hidden_size","(","num",")",":","the","input","and","output","hidden","size",".","Default",":","64","-","inner_size","(","num",")",":","the","dimensionality","in","feed-forward","layer",".","Default",":","256","-","hidden_dropout_prob","(","float",")",":","probability","of","an","element","to","be","zeroed",".","Default",":","0.5","-","attn_dropout_prob","(","float",")",":","probability","of","an","attention","score","to","be","zeroed",".","Default",":","0.5","-","hidden_act","(","str",")",":","activation","function","in","feed-forward","layer",".","Default",":","'gelu'","candidates",":","'gelu","'",",","'relu","'",",","'swish","'",",","'tanh","'",",","'sigmoid'","-","layer_norm_eps","(","float",")",":","a","value","added","to","the","denominator","for","numerical","stability",".","Default",":","1e-12"]
docstr: Args:
      hidden_states (torch.Tensor): the input of the TransformerEncoder
      attention_mask (torch.Tensor): the attention mask for the input hidden_states
      output_all_encoded_layers (Bool): whether output all transformer layers' output
  
  Returns:
      all_encoder_layers (list): if output_all_encoded_layers is True, return a list consists of all transformer
      layers' output, otherwise return a list only consists of the output of last transformer layer.
docstr_tok: ["Args",":","hidden_states","(","torch.Tensor",")",":","the","input","of","the","TransformerEncoder","attention_mask","(","torch.Tensor",")",":","the","attention","mask","for","the","input","hidden_states","output_all_encoded_layers","(","Bool",")",":","whether","output","all","transformer","layers","'","output","Returns",":","all_encoder_layers","(","list",")",":","if","output_all_encoded_layers","is","True",",","return","a","list","consists","of","all","transformer","layers","'","output",",","otherwise","return","a","list","only","consists","of","the","output","of","last","transformer","layer","."]
code: def forward(
      self,
      hidden_states,
      attention_mask,
      output_all_encoded_layers=True,
  ):
      """
      Args:
          hidden_states (torch.Tensor): the input of the TransformerEncoder
          attention_mask (torch.Tensor): the attention mask for the input hidden_states
          output_all_encoded_layers (Bool): whether output all transformer layers' output
  
      Returns:
          all_encoder_layers (list): if output_all_encoded_layers is True, return a list consists of all transformer
          layers' output, otherwise return a list only consists of the output of last transformer layer.
  
      """
      all_encoder_layers = []
  
      for layer_module in self.layer:
          hidden_states = layer_module(hidden_states, attention_mask)
          if output_all_encoded_layers:
              all_encoder_layers.append(hidden_states)
      if not output_all_encoded_layers:
          all_encoder_layers.append(hidden_states)
      return all_encoder_layers
  
imports: import random
  import numpy
  import torch
  from torch import nn
  import torch.nn.functional
  import math
  import torch.nn.functional
  from recbole.model.abstract_recommender import SequentialRecommender
  from recbole.model.loss import BPRLoss
  from recbole.data.interaction import Interaction
label_desc: Use image node_id 2 for calling the FEAEncoder obj's underlying member method code with example usage: obj.forward(hidden_states, attention_mask, output_all_encoded_layers) and returns: all_encoder_layers