class_docstr: embedding.HistoryArch is the input embedding layer the BERT4Rec model
  as described in Section 3.4 of the paper.  It consits of an item
  embedding table and a positional embedding table.
  
  The item embedding table consists of vocab_size vectors.  The
  positional embedding table has history_len vectors.  Both
  kinds of embedding vectors have length emb_dim.  As mentioned
  in Section 3.7, BERT4Rec differs from BERT lacking the
  sentence embedding.
  
  Note that for the item embedding table, we have applied TorchRec
  EmbeddingCollection which supports sharding
  
  Args:
      vocab_size (int): the item count including mask and padding
      history_len (int): the max length
      emb_dim (int): embedding dimension
      dropout (float): the dropout probability
      device: (Optional[torch.device]).
  
  Example::
  
      self.history = HistoryArch(
          vocab_size, max_len, emb_dim, dropout=dropout, device=device
      )
      x = self.history(input)
class_docstr_tok: ["embedding.HistoryArch","is","the","input","embedding","layer","the","BERT4Rec","model","as","described","in","Section","3.4","of","the","paper",".","It","consits","of","an","item","embedding","table","and","a","positional","embedding","table",".","The","item","embedding","table","consists","of","vocab_size","vectors",".","The","positional","embedding","table","has","history_len","vectors",".","Both","kinds","of","embedding","vectors","have","length","emb_dim",".","As","mentioned","in","Section","3.7",",","BERT4Rec","differs","from","BERT","lacking","the","sentence","embedding",".","Note","that","for","the","item","embedding","table",",","we","have","applied","TorchRec","EmbeddingCollection","which","supports","sharding","Args",":","vocab_size","(","int",")",":","the","item","count","including","mask","and","padding","history_len","(","int",")",":","the","max","length","emb_dim","(","int",")",":","embedding","dimension","dropout","(","float",")",":","the","dropout","probability","device",":","(","Optional","[","torch.device","]",")",".","Example",":",":","self.history","=","HistoryArch","(","vocab_size",",","max_len",",","emb_dim",",","dropout=dropout",",","device=device",")","x","=","self.history","(","input",")"]
docstr: forward function: first query the item embedding and do the padding
  then add up with positional parameters and do the norm and dropout
  
  Args:
      id_list_features (KeyedJaggedTensor): the input KeyedJaggedTensor
  
  Returns:
      torch.Tensor.
docstr_tok: ["forward","function",":","first","query","the","item","embedding","and","do","the","padding","then","add","up","with","positional","parameters","and","do","the","norm","and","dropout","Args",":","id_list_features","(","KeyedJaggedTensor",")",":","the","input","KeyedJaggedTensor","Returns",":","torch.Tensor","."]
code: def forward(
      self, id_list_features: KeyedJaggedTensor
  ) -> torch.Tensor:
      """
      forward function: first query the item embedding and do the padding
      then add up with positional parameters and do the norm and dropout
  
      Args:
          id_list_features (KeyedJaggedTensor): the input KeyedJaggedTensor
  
      Returns:
          torch.Tensor.
      """
      jt_dict = self.ec(id_list_features)
  
      padded_embeddings = [
          torch.ops.fbgemm.jagged_2d_to_dense(
              values=jt_dict[e].values(),
              offsets=jt_dict[e].offsets(),
              max_sequence_length=self.history_len,
          ).view(-1, self.history_len, self.emb_dim)
          for e in id_list_features.keys()
      ]
      item_output = torch.cat(
          padded_embeddings,
          dim=1,
      )
      batch_size = id_list_features.stride()
      positional_output = self.positional.unsqueeze(0).repeat(
          batch_size, 1, 1
      )
      x = item_output + positional_output
      return self.dropout(self.layernorm(x))
  
imports: import copy
  import math
  from typing import Callable, Optional, Tuple
  import torch
  import torch.nn
  from torchrec.modules.embedding_configs import EmbeddingConfig
  from torchrec.modules.embedding_modules import EmbeddingCollection
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
label_desc: Use image node_id 2 for calling the HistoryArch obj's underlying member method code with example usage: obj.forward(id_list_features) and returns: self