class_docstr: ENMF is an efficient non-sampling model for general recommendation.
  In order to run non-sampling model, please set the neg_sampling parameter as None .
class_docstr_tok: ["ENMF","is","an","efficient","non-sampling","model","for","general","recommendation",".","In","order","to","run","non-sampling","model",",","please","set","the","neg_sampling","parameter","as","None","."]
code: def calculate_loss(self, interaction):
      user = interaction[self.USER_ID]
  
      pos_score = self.forward(user)
  
      # shape: [embedding_size, embedding_size]
      item_sum = torch.bmm(
          self.item_embedding.weight.unsqueeze(2),
          self.item_embedding.weight.unsqueeze(1),
      ).sum(dim=0)
  
      # shape: [embedding_size, embedding_size]
      batch_user = self.user_embedding(user)
      user_sum = torch.bmm(
          batch_user.unsqueeze(2), batch_user.unsqueeze(1)
      ).sum(dim=0)
  
      # shape: [embedding_size, embedding_size]
      H_sum = torch.matmul(self.H_i.weight.t(), self.H_i.weight)
  
      t = torch.sum(item_sum * user_sum * H_sum)
  
      loss = self.negative_weight * t
  
      loss = loss + torch.sum(
          (1 - self.negative_weight) * torch.square(pos_score)
          - 2 * pos_score
      )
  
      loss = loss + self.reg_loss()
  
      return loss
  
file_path: RecBole/recbole/model/general_recommender/enmf.py
imports: import torch
  import torch.nn
  from recbole.model.init import xavier_normal_initialization
  from recbole.utils import InputType
  from recbole.model.abstract_recommender import GeneralRecommender
label_desc: Use image node_id 4 for calling the ENMF obj's underlying member method code with example usage: obj.calculate_loss(interaction) and returns: loss