class_docstr: GRU4Rec is a model that incorporate RNN for recommendation.
  
  Note:
  
      Regarding the innovation of this article,we can only achieve the data augmentation mentioned
      in the paper and directly output the embedding of the item,
      in order that the generation method we used is common to other sequential models.
class_docstr_tok: ["GRU4Rec","is","a","model","that","incorporate","RNN","for","recommendation",".","Note",":","Regarding","the","innovation","of","this","article",",","we","can","only","achieve","the","data","augmentation","mentioned","in","the","paper","and","directly","output","the","embedding","of","the","item",",","in","order","that","the","generation","method","we","used","is","common","to","other","sequential","models","."]
code: def __init__(self, config, dataset):
      super(GRU4RecCPR, self).__init__(config, dataset)
  
      # load parameters info
      self.hidden_size = config["hidden_size"]
      self.embedding_size = config["embedding_size"]
      self.loss_type = config["loss_type"]
      self.num_layers = config["num_layers"]
      self.dropout_prob = config["dropout_prob"]
  
      self.n_facet_all = config["n_facet_all"]  # added for mfs
      self.n_facet = config["n_facet"]  # added for mfs
      self.n_facet_window = config["n_facet_window"]  # added for mfs
      self.n_facet_hidden = min(
          config["n_facet_hidden"], config["num_layers"]
      )  # config['n_facet_hidden'] #added for mfs
      self.n_facet_MLP = config["n_facet_MLP"]  # added for mfs
      self.n_facet_context = config[
          "n_facet_context"
      ]  # added for dynamic partioning
      self.n_facet_reranker = config[
          "n_facet_reranker"
      ]  # added for dynamic partioning
      self.n_facet_emb = config[
          "n_facet_emb"
      ]  # added for dynamic partioning
      assert self.n_facet_MLP <= 0  # -1 or 0
      assert self.n_facet_window <= 0
      self.n_facet_window = -self.n_facet_window
      self.n_facet_MLP = -self.n_facet_MLP
      self.softmax_nonlinear = "None"  # added for mfs
      self.use_out_emb = config["use_out_emb"]  # added for mfs
      self.only_compute_loss = True  # added for mfs
  
      self.dense = nn.Linear(self.hidden_size, self.embedding_size)
      out_size = self.embedding_size
  
      self.n_embd = out_size
  
      self.use_proj_bias = config["use_proj_bias"]  # added for mfs
      self.weight_mode = config["weight_mode"]  # added for mfs
      self.context_norm = config["context_norm"]  # added for mfs
      self.post_remove_context = config[
          "post_remove_context"
      ]  # added for mfs
      self.reranker_merging_mode = config[
          "reranker_merging_mode"
      ]  # added for mfs
      self.partition_merging_mode = config[
          "partition_merging_mode"
      ]  # added for mfs
      self.reranker_CAN_NUM = [
          int(x) for x in str(config["reranker_CAN_NUM"]).split(",")
      ]
      assert self.use_proj_bias is not None
      self.candidates_from_previous_reranker = True
      if self.weight_mode == "max_logits":
          self.n_facet_effective = 1
      else:
          self.n_facet_effective = self.n_facet
  
      assert (
          self.n_facet
          + self.n_facet_context
          + self.n_facet_reranker * len(self.reranker_CAN_NUM)
          + self.n_facet_emb
          == self.n_facet_all
      )
      assert self.n_facet_emb == 0 or self.n_facet_emb == 2
  
      hidden_state_input_ratio = 1 + self.n_facet_MLP  # 1 + 1
      self.MLP_linear = nn.Linear(
          self.n_embd
          * (self.n_facet_hidden * (self.n_facet_window + 1)),
          self.n_embd * self.n_facet_MLP,
      )  # (hid_dim*2) -> (hid_dim)
      total_lin_dim = self.n_embd * hidden_state_input_ratio
      self.project_arr = nn.ModuleList(
          [
              nn.Linear(
                  total_lin_dim, self.n_embd, bias=self.use_proj_bias
              )
              for i in range(self.n_facet_all)
          ]
      )
  
      self.project_emb = nn.Linear(
          self.n_embd, self.n_embd, bias=self.use_proj_bias
      )
      if len(self.weight_mode) > 0:
          self.weight_facet_decoder = nn.Linear(
              self.n_embd * hidden_state_input_ratio,
              self.n_facet_effective,
          )
          self.weight_global = nn.Parameter(
              torch.ones(self.n_facet_effective)
          )
  
      self.c = 123
  
      # define layers and loss
      self.emb_dropout = nn.Dropout(self.dropout_prob)
      self.gru_layers = nn.GRU(
          input_size=self.embedding_size,
          hidden_size=self.hidden_size,
          num_layers=self.num_layers,
          bias=False,
          batch_first=True,
      )
      self.item_embedding = nn.Embedding(
          self.n_items, self.embedding_size, padding_idx=0
      )
  
      if self.use_out_emb:
          self.out_item_embedding = nn.Linear(
              out_size, self.n_items, bias=False
          )
      else:
          self.out_item_embedding = self.item_embedding
          self.out_item_embedding.bias = None
  
      if self.loss_type == "BPR":
          print("current softmax-cpr code does not support BPR loss")
          sys.exit(0)
      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/gru4reccpr.py
imports: import torch
  from torch import nn
  from torch.nn.init import xavier_uniform_, xavier_normal_
  import torch.nn.functional
  import math
  from recbole.model.abstract_recommender import SequentialRecommender
  from recbole.model.loss import BPRLoss
  import sys
label_desc: Use image node_id 1 to create a new GRU4RecCPR object from inherited base classes: SequentialRecommender with example: obj = GRU4RecCPR(config, dataset)