class_docstr: BPR is a basic matrix factorization model that be trained in the pairwise way.
class_docstr_tok: ["BPR","is","a","basic","matrix","factorization","model","that","be","trained","in","the","pairwise","way","."]
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_e = self.forward(user, pos_item)
      neg_e = self.get_item_embedding(neg_item)
      pos_item_score, neg_item_score = torch.mul(user_e, pos_e).sum(
          dim=1
      ), torch.mul(user_e, neg_e).sum(dim=1)
      loss = self.loss(pos_item_score, neg_item_score)
      return loss
  
file_path: RecBole/recbole/model/general_recommender/bpr.py
imports: import torch
  import torch.nn
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.loss import BPRLoss
  from recbole.utils import InputType
label_desc: Use image node_id 5 for calling the BPR obj's underlying member method code with example usage: obj.calculate_loss(interaction) and returns: loss