class_docstr: NGCF is a model that incorporate GNN for recommendation.
  We implement the model following the original author with a pairwise training mode.
class_docstr_tok: ["NGCF","is","a","model","that","incorporate","GNN","for","recommendation",".","We","implement","the","model","following","the","original","author","with","a","pairwise","training","mode","."]
code: def calculate_loss(self, interaction):
      # clear the storage variable when training
      if (
          self.restore_user_e is not None
          or self.restore_item_e is not None
      ):
          self.restore_user_e, self.restore_item_e = None, None
  
      user = interaction[self.USER_ID]
      pos_item = interaction[self.ITEM_ID]
      neg_item = interaction[self.NEG_ITEM_ID]
  
      user_all_embeddings, item_all_embeddings = self.forward()
      u_embeddings = user_all_embeddings[user]
      pos_embeddings = item_all_embeddings[pos_item]
      neg_embeddings = item_all_embeddings[neg_item]
  
      pos_scores = torch.mul(u_embeddings, pos_embeddings).sum(dim=1)
      neg_scores = torch.mul(u_embeddings, neg_embeddings).sum(dim=1)
      mf_loss = self.mf_loss(
          pos_scores, neg_scores
      )  # calculate BPR Loss
  
      reg_loss = self.reg_loss(
          u_embeddings, pos_embeddings, neg_embeddings
      )  # L2 regularization of embeddings
  
      return mf_loss + self.reg_weight * reg_loss
  
file_path: RecBole/recbole/model/general_recommender/ngcf.py
imports: import numpy
  import scipy.sparse
  import torch
  import torch.nn
  import torch.nn.functional
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.layers import BiGNNLayer, SparseDropout
  from recbole.model.loss import BPRLoss, EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 6 for calling the NGCF obj's underlying member method code with example usage: obj.calculate_loss(interaction) and returns: unknown