class_docstr: SHAN exploit the Hierarchical Attention Network to get the long-short term preference
  first get the long term purpose and then fuse the long-term with recent items to get long-short term purpose
class_docstr_tok: ["SHAN","exploit","the","Hierarchical","Attention","Network","to","get","the","long-short","term","preference","first","get","the","long","term","purpose","and","then","fuse","the","long-term","with","recent","items","to","get","long-short","term","purpose"]
code: def __init__(self, config, dataset):
      super(SHAN, self).__init__(config, dataset)
  
      # load the dataset information
      self.n_users = dataset.num(self.USER_ID)
      self.device = config["device"]
      self.INVERSE_ITEM_SEQ = config["INVERSE_ITEM_SEQ"]
  
      # load the parameter information
      self.embedding_size = config["embedding_size"]
      self.short_item_length = config[
          "short_item_length"
      ]  # the length of the short session items
      assert (
          self.short_item_length <= self.max_seq_length
      ), "short_item_length can't longer than the max_seq_length"
      self.reg_weight = config["reg_weight"]
  
      # define layers and loss
      self.item_embedding = nn.Embedding(
          self.n_items, self.embedding_size, padding_idx=0
      )
      self.user_embedding = nn.Embedding(
          self.n_users, self.embedding_size
      )
  
      self.long_w = nn.Linear(self.embedding_size, self.embedding_size)
      self.long_b = nn.Parameter(
          uniform_(
              tensor=torch.zeros(self.embedding_size),
              a=-np.sqrt(3 / self.embedding_size),
              b=np.sqrt(3 / self.embedding_size),
          ),
          requires_grad=True,
      )
      self.long_short_w = nn.Linear(
          self.embedding_size, self.embedding_size
      )
      self.long_short_b = nn.Parameter(
          uniform_(
              tensor=torch.zeros(self.embedding_size),
              a=-np.sqrt(3 / self.embedding_size),
              b=np.sqrt(3 / self.embedding_size),
          ),
          requires_grad=True,
      )
  
      self.relu = nn.ReLU()
  
      self.loss_type = config["loss_type"]
      if self.loss_type == "BPR":
          self.loss_fct = BPRLoss()
      elif self.loss_type == "CE":
          self.loss_fct = nn.CrossEntropyLoss()
      else:
          raise NotImplementedError(
              "Make sure 'loss_type' in ['BPR', 'CE']!"
          )
  
      # init the parameter of the model
      self.apply(self.init_weights)
  
file_path: RecBole/recbole/model/sequential_recommender/shan.py
imports: import numpy
  import torch
  import torch.nn
  from torch.nn.init import normal_, uniform_
  from recbole.model.abstract_recommender import SequentialRecommender
  from recbole.model.loss import BPRLoss
label_desc: Use image node_id 1 to create a new SHAN object from inherited base classes: SequentialRecommender with example: obj = SHAN(config, dataset)