class_docstr: SAS Rec model
  Self-Attentive Sequential Recommendation Using Transformer
  
  :Citation:
  
      Wang-Cheng Kang, Julian McAuley (2018), Self-Attentive Sequential
      Recommendation. Proceedings of IEEE International Conference on
      Data Mining (ICDM'18)
  
      Original source code from nnkkmto/SASRec-tf2,
      https://github.com/nnkkmto/SASRec-tf2
docstr: Model initialization.
  
  Args:
      item_num (int): Number of items in the dataset.
      seq_max_len (int): Maximum number of items in user history.
      num_blocks (int): Number of Transformer blocks to be used.
      embedding_dim (int): Item embedding dimension.
      attention_dim (int): Transformer attention dimension.
      conv_dims (list): List of the dimensions of the Feedforward layer.
      dropout_rate (float): Dropout rate.
      l2_reg (float): Coefficient of the L2 regularization.
      num_neg_test (int): Number of negative examples used in testing.
docstr_tok: ["Model","initialization",".","Args",":","item_num","(","int",")",":","Number","of","items","in","the","dataset",".","seq_max_len","(","int",")",":","Maximum","number","of","items","in","user","history",".","num_blocks","(","int",")",":","Number","of","Transformer","blocks","to","be","used",".","embedding_dim","(","int",")",":","Item","embedding","dimension",".","attention_dim","(","int",")",":","Transformer","attention","dimension",".","conv_dims","(","list",")",":","List","of","the","dimensions","of","the","Feedforward","layer",".","dropout_rate","(","float",")",":","Dropout","rate",".","l2_reg","(","float",")",":","Coefficient","of","the","L2","regularization",".","num_neg_test","(","int",")",":","Number","of","negative","examples","used","in","testing","."]
code: def __init__(self, **kwargs):
      """Model initialization.
  
      Args:
          item_num (int): Number of items in the dataset.
          seq_max_len (int): Maximum number of items in user history.
          num_blocks (int): Number of Transformer blocks to be used.
          embedding_dim (int): Item embedding dimension.
          attention_dim (int): Transformer attention dimension.
          conv_dims (list): List of the dimensions of the Feedforward layer.
          dropout_rate (float): Dropout rate.
          l2_reg (float): Coefficient of the L2 regularization.
          num_neg_test (int): Number of negative examples used in testing.
      """
      super(SASREC, self).__init__()
  
      self.item_num = kwargs.get("item_num", None)
      self.seq_max_len = kwargs.get("seq_max_len", 100)
      self.num_blocks = kwargs.get("num_blocks", 2)
      self.embedding_dim = kwargs.get("embedding_dim", 100)
      self.attention_dim = kwargs.get("attention_dim", 100)
      self.attention_num_heads = kwargs.get("attention_num_heads", 1)
      self.conv_dims = kwargs.get("conv_dims", [100, 100])
      self.dropout_rate = kwargs.get("dropout_rate", 0.5)
      self.l2_reg = kwargs.get("l2_reg", 0.0)
      self.num_neg_test = kwargs.get("num_neg_test", 100)
  
      self.item_embedding_layer = tf.keras.layers.Embedding(
          self.item_num + 1,
          self.embedding_dim,
          name="item_embeddings",
          mask_zero=True,
          embeddings_regularizer=tf.keras.regularizers.L2(self.l2_reg),
      )
  
      self.positional_embedding_layer = tf.keras.layers.Embedding(
          self.seq_max_len,
          self.embedding_dim,
          name="positional_embeddings",
          mask_zero=False,
          embeddings_regularizer=tf.keras.regularizers.L2(self.l2_reg),
      )
      self.dropout_layer = tf.keras.layers.Dropout(self.dropout_rate)
      self.encoder = Encoder(
          self.num_blocks,
          self.seq_max_len,
          self.embedding_dim,
          self.attention_dim,
          self.attention_num_heads,
          self.conv_dims,
          self.dropout_rate,
      )
      self.mask_layer = tf.keras.layers.Masking(mask_value=0)
      self.layer_normalization = LayerNormalization(
          self.seq_max_len, self.embedding_dim, 1e-08
      )
  
imports: import random
  import numpy
  from tqdm import tqdm
  import tensorflow
  from recommenders.utils.timer import Timer
label_desc: Use image node_id 1 to create a new SASREC object from inherited base classes: tf.keras with example: obj = SASREC()