class_docstr: KGCN is a knowledge-based recommendation model that captures inter-item relatedness effectively by mining their
  associated attributes on the KG. To automatically discover both high-order structure information and semantic
  information of the KG, we treat KG as an undirected graph and sample from the neighbors for each entity in the KG
  as their receptive field, then combine neighborhood information with bias when calculating the representation of a
  given entity.
class_docstr_tok: ["KGCN","is","a","knowledge-based","recommendation","model","that","captures","inter-item","relatedness","effectively","by","mining","their","associated","attributes","on","the","KG",".","To","automatically","discover","both","high-order","structure","information","and","semantic","information","of","the","KG",",","we","treat","KG","as","an","undirected","graph","and","sample","from","the","neighbors","for","each","entity","in","the","KG","as","their","receptive","field",",","then","combine","neighborhood","information","with","bias","when","calculating","the","representation","of","a","given","entity","."]
code: def calculate_loss(self, interaction):
      user = interaction[self.USER_ID]
      pos_item = interaction[self.ITEM_ID]
      neg_item = interaction[self.NEG_ITEM_ID]
  
      user_e, pos_item_e = self.forward(user, pos_item)
      user_e, neg_item_e = self.forward(user, neg_item)
  
      pos_item_score = torch.mul(user_e, pos_item_e).sum(dim=1)
      neg_item_score = torch.mul(user_e, neg_item_e).sum(dim=1)
  
      predict = torch.cat((pos_item_score, neg_item_score))
      target = torch.zeros(len(user) * 2, dtype=torch.float32).to(
          self.device
      )
      target[: len(user)] = 1
      rec_loss = self.bce_loss(predict, target)
  
      l2_loss = self.l2_loss(user_e, pos_item_e, neg_item_e)
      loss = rec_loss + self.reg_weight * l2_loss
  
      return loss
  
file_path: RecBole/recbole/model/knowledge_aware_recommender/kgcn.py
imports: import numpy
  import torch
  import torch.nn
  from recbole.model.abstract_recommender import KnowledgeRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.loss import EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 7 for calling the KGCN obj's underlying member method code with example usage: obj.calculate_loss(interaction) and returns: loss