class_docstr: SimpleX is a simple, unified collaborative filtering model.
  
  SimpleX presents a simple and easy-to-understand model. Its advantage lies
  in its loss function, which uses a larger number of negative samples and
  sets a threshold to filter out less informative samples, it also uses
  relative weights to control the balance of positive-sample loss
  and negative-sample loss.
  
  We implement the model following the original author with a pairwise training mode.
docstr: Data processing and call function forward(), return loss
  
  To use SimpleX, a user must have a historical transaction record,
  a pos item and a sequence of neg items. Based on the RecBole
  framework, the data in the interaction object is ordered, so
  we can get the data quickly.
docstr_tok: ["Data","processing","and","call","function","forward","(",")",",","return","loss","To","use","SimpleX",",","a","user","must","have","a","historical","transaction","record",",","a","pos","item","and","a","sequence","of","neg","items",".","Based","on","the","RecBole","framework",",","the","data","in","the","interaction","object","is","ordered",",","so","we","can","get","the","data","quickly","."]
code: def calculate_loss(self, interaction):
      r"""Data processing and call function forward(), return loss
  
      To use SimpleX, a user must have a historical transaction record,
      a pos item and a sequence of neg items. Based on the RecBole
      framework, the data in the interaction object is ordered, so
      we can get the data quickly.
      """
      user = interaction[self.USER_ID]
      pos_item = interaction[self.ITEM_ID]
      neg_item = interaction[self.NEG_ITEM_ID]
  
      # get the sequence of neg items
      neg_item_seq = neg_item.reshape((self.neg_seq_len, -1))
      neg_item_seq = neg_item_seq.T
      user_number = int(len(user) / self.neg_seq_len)
      # user's id
      user = user[0:user_number]
      # historical transaction record
      history_item = self.history_item_id[user]
      # positive item's id
      pos_item = pos_item[0:user_number]
      # history_len
      history_len = self.history_item_len[user]
  
      loss = self.forward(
          user, pos_item, history_item, history_len, neg_item_seq
      )
      return loss
  
file_path: RecBole/recbole/model/general_recommender/simplex.py
imports: import torch
  from torch import nn
  import torch.nn.functional
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.loss import EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 5 for calling the SimpleX obj's underlying member method code with example usage: obj.calculate_loss(interaction) and returns: loss