class_docstr: Loss
class_docstr_tok: ["Loss"]
code: def _crossentropy(self, input, target, use_pure_fp16=False):
      if self._label_smoothing:
          target = self._labelsmoothing(target)
          input = -F.log_softmax(input, axis=-1)
          cost = paddle.sum(target * input, axis=-1)
      else:
          cost = F.cross_entropy(input=input, label=target)
      if use_pure_fp16:
          avg_cost = paddle.sum(cost)
      else:
          avg_cost = paddle.mean(cost)
      return avg_cost
  
imports: import paddle
  import paddle.nn.functional
label_desc: Use image node_id 3 for calling the Loss obj's underlying member method code with example usage: obj._crossentropy(input, target, use_pure_fp16) and returns: avg_cost