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",")"]
code: def __init__(
      self,
      vocab_size: int,
      history_len: int,
      emb_dim: int,
      dropout: float = 0.1,
      device: Optional[torch.device] = None,
  ) -> None:
      super().__init__()
      self.emb_dim = emb_dim
      self.history_len = history_len
      self.positional = nn.Parameter(
          torch.randn(history_len, emb_dim, device=device)
      )
      self.layernorm = torch.nn.LayerNorm(
          [history_len, emb_dim], device=device
      )
      self.dropout = torch.nn.Dropout(p=dropout)
  
      item_embedding_config = EmbeddingConfig(
          name="item_embedding",
          embedding_dim=emb_dim,
          num_embeddings=vocab_size,
          feature_names=["item"],
          weight_init_max=1.0,
          weight_init_min=-1.0,
      )
      self.ec = EmbeddingCollection(
          tables=[item_embedding_config],
          device=device,
      )
  
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 1 to create a new HistoryArch object from inherited base classes: torch.nn with example: obj = HistoryArch(vocab_size, history_len, emb_dim, dropout, device)