class_docstr: KSR integrates the RNN-based networks with Key-Value Memory Network (KV-MN).
  And it further incorporates knowledge base (KB) information to enhance the semantic representation of KV-MN.
class_docstr_tok: ["KSR","integrates","the","RNN-based","networks","with","Key-Value","Memory","Network","(","KV-MN",")",".","And","it","further","incorporates","knowledge","base","(","KB",")","information","to","enhance","the","semantic","representation","of","KV-MN","."]
code: def forward(self, item_seq, item_seq_len):
      # sequential preference h^u_t
      item_seq_emb = self.item_embedding(item_seq)
      item_seq_emb_dropout = self.emb_dropout(item_seq_emb)
      gru_output, _ = self.gru_layers(item_seq_emb_dropout)
      seq_output = self.gather_indexes(
          gru_output, item_seq_len - 1
      )  # [B H]
  
      # attribute-based preference representation, m^u_t
      user_memory = self.memory_update(
          item_seq, item_seq_len
      )  # [B R K]
  
      # We need to make the same dimension (batch_size, kg_embedding_size).
      seq_output_trans = self.dense(seq_output)  # [B K]
      u_m = self.memory_read(seq_output_trans, user_memory)  # [B K]
  
      # combine them together
      p_u = self.dense_layer_u(
          torch.cat((seq_output, u_m), -1)
      )  # [B E]
      return p_u
  
file_path: RecBole/recbole/model/sequential_recommender/ksr.py
imports: import torch
  from torch import nn
  from torch.nn.init import xavier_uniform_, xavier_normal_
  from recbole.model.abstract_recommender import SequentialRecommender
  from recbole.model.loss import BPRLoss
label_desc: Use image node_id 7 for calling the KSR obj's underlying member method code with example usage: obj.forward(item_seq, item_seq_len) and returns: p_u