class_docstr: Loss functions.
  
  Args:
      name (str):
          Loss function name.
      margin (float, optional):
          Margin parameter for MarginRankingLoss.
      pairwise (bool, optional):
          Whether compute loss of positive and negative samples pairwise.
      neg_adv_spl (bool, optional):
          Whether use negative adversarial sampling.
      neg_adv_temp (float, optional):
          Temperature of negative adversarial sampling.
class_docstr_tok: ["Loss","functions",".","Args",":","name","(","str",")",":","Loss","function","name",".","margin","(","float",",","optional",")",":","Margin","parameter","for","MarginRankingLoss",".","pairwise","(","bool",",","optional",")",":","Whether","compute","loss","of","positive","and","negative","samples","pairwise",".","neg_adv_spl","(","bool",",","optional",")",":","Whether","use","negative","adversarial","sampling",".","neg_adv_temp","(","float",",","optional",")",":","Temperature","of","negative","adversarial","sampling","."]
code: def __call__(self, pos_score, neg_score, weights=None):
      if self.pairwise:
          pos_score = paddle.unsqueeze(pos_score, -1)
          loss = paddle.mean(self.loss_func(pos_score - neg_score, 1))
      else:
          if self.name == "Logsigmoid":
              pos_loss = self.loss_func(pos_score, 1, weights)
              neg_loss = self.loss_func(
                  neg_score, self.neg_label, weights
              )
          else:
              pos_loss = self.loss_func(pos_score, 1)
              neg_loss = self.loss_func(neg_score, self.neg_label)
          if self.neg_adv_spl:
              neg_loss = neg_loss * self.adverarial_weight(neg_score)
              neg_loss = paddle.sum(neg_loss, axis=-1)
          else:
              neg_loss = paddle.mean(neg_loss, axis=-1)
  
          pos_loss = paddle.mean(pos_loss)
          neg_loss = paddle.mean(neg_loss)
          loss = (pos_loss + neg_loss) / 2
      return loss
  
file_path: PGL/apps/Graph4KG/models/loss_func.py
imports: import paddle
  from paddle.nn import BCELoss, MarginRankingLoss
  from paddle.nn.functional import log_sigmoid, softmax, softplus
label_desc: Use image node_id 2 for calling the LossFunction obj's underlying member method code with example usage: obj.__call__(pos_score, neg_score, weights) and returns: loss