docstr: Args:
      pred (Tensor): result of  `self.forward`
      label (Tensor): label can be None if you use unsupervised training
  Returns:
      return (paddle scalar): loss
docstr_tok: ["Args",":","pred","(","Tensor",")",":","result","of","`","self.forward","`","label","(","Tensor",")",":","label","can","be","None","if","you","use","unsupervised","training","Returns",":","return","(","paddle","scalar",")",":","loss"]
code: def loss(self, pred, label=None):
      """
      Args:
          pred (Tensor): result of  `self.forward`
          label (Tensor): label can be None if you use unsupervised training
      Returns:
          return (paddle scalar): loss
      """
  
      pos_logits = pred[:, 0:1]
      neg_logits = pred[:, 1:]
  
      ones_label = paddle.ones_like(pos_logits)
      zeros_label = paddle.zeros_like(neg_logits)
      pos_loss = self.loss_fn(pos_logits, ones_label)
      neg_loss = self.loss_fn(neg_logits, zeros_label)
  
      loss = (pos_loss + neg_loss) / 2
  
      return loss
  
imports: import math
  import time
  from collections import OrderedDict
  import paddle
  import paddle.nn
  import paddle.distributed.fleet
  import pgl
  import pgl.nn
  from pgl.distributed import helper
  from collections import OrderedDict
  import models.embedding
  import models.layers
label_desc: Use image node_id 5 for calling the WalkBasedModel obj's underlying member method code with example usage: obj.loss(pred, label) and returns: loss