class_docstr: MKR is a Multi-task feature learning approach for Knowledge graph enhanced Recommendation. It is a deep
  end-to-end framework that utilizes knowledge graph embedding task to assist recommendation task. The two
  tasks are associated by cross&compress units, which automatically share latent features and learn high-order
  interactions between items in recommender systems and entities in the knowledge graph.
class_docstr_tok: ["MKR","is","a","Multi-task","feature","learning","approach","for","Knowledge","graph","enhanced","Recommendation",".","It","is","a","deep","end-to-end","framework","that","utilizes","knowledge","graph","embedding","task","to","assist","recommendation","task",".","The","two","tasks","are","associated","by","cross","&","compress","units",",","which","automatically","share","latent","features","and","learn","high-order","interactions","between","items","in","recommender","systems","and","entities","in","the","knowledge","graph","."]
docstr: Calculate the training loss for a batch data of RS.
docstr_tok: ["Calculate","the","training","loss","for","a","batch","data","of","RS","."]
code: def calculate_rs_loss(self, interaction):
      r"""Calculate the training loss for a batch data of RS."""
      # inputs
      self.user_indices = interaction[self.USER_ID]
      self.item_indices = interaction[self.ITEM_ID]
      self.head_indices = interaction[self.ITEM_ID]
      self.labels = interaction[self.LABEL]
      # RS model
      (
          user_embeddings,
          item_embeddings,
          scores,
          scores_normalized,
      ) = self.forward(
          user_indices=self.user_indices,
          item_indices=self.item_indices,
          head_indices=self.head_indices,
          relation_indices=None,
          tail_indices=None,
      )
      # loss
      base_loss_rs = torch.mean(self.sigmoid_BCE(scores, self.labels))
      l2_loss_rs = self._l2_loss(user_embeddings) + self._l2_loss(
          item_embeddings
      )
      loss_rs = base_loss_rs + l2_loss_rs * self.reg_weight
  
      return loss_rs
  
file_path: RecBole/recbole/model/knowledge_aware_recommender/mkr.py
imports: import torch
  import torch.nn
  from recbole.model.abstract_recommender import KnowledgeRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.layers import MLPLayers
  from recbole.utils import InputType
label_desc: Use image node_id 4 for calling the MKR obj's underlying member method code with example usage: obj.calculate_rs_loss(interaction) and returns: loss_rs