class_docstr: NARM explores a hybrid encoder with an attention mechanism to model the user’s sequential behavior,
  and capture the user’s main purpose in the current session.
class_docstr_tok: ["NARM","explores","a","hybrid","encoder","with","an","attention","mechanism","to","model","the","user","\u2019","s","sequential","behavior",",","and","capture","the","user","\u2019","s","main","purpose","in","the","current","session","."]
code: def __init__(self, config, dataset):
      super(NARM, self).__init__(config, dataset)
  
      # load parameters info
      self.embedding_size = config["embedding_size"]
      self.hidden_size = config["hidden_size"]
      self.n_layers = config["n_layers"]
      self.dropout_probs = config["dropout_probs"]
      self.device = config["device"]
  
      # define layers and loss
      self.item_embedding = nn.Embedding(
          self.n_items, self.embedding_size, padding_idx=0
      )
      self.emb_dropout = nn.Dropout(self.dropout_probs[0])
      self.gru = nn.GRU(
          self.embedding_size,
          self.hidden_size,
          self.n_layers,
          bias=False,
          batch_first=True,
      )
      self.a_1 = nn.Linear(
          self.hidden_size, self.hidden_size, bias=False
      )
      self.a_2 = nn.Linear(
          self.hidden_size, self.hidden_size, bias=False
      )
      self.v_t = nn.Linear(self.hidden_size, 1, bias=False)
      self.ct_dropout = nn.Dropout(self.dropout_probs[1])
      self.b = nn.Linear(
          2 * self.hidden_size, self.embedding_size, bias=False
      )
      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']!"
          )
  
      # parameters initialization
      self.apply(self._init_weights)
  
file_path: RecBole/recbole/model/sequential_recommender/narm.py
imports: import torch
  from torch import nn
  from torch.nn.init import xavier_normal_, constant_
  from recbole.model.abstract_recommender import SequentialRecommender
  from recbole.model.loss import BPRLoss
label_desc: Use image node_id 1 to create a new NARM object from inherited base classes: SequentialRecommender with example: obj = NARM(config, dataset)