code: def distribution_focal_loss(pred, label):
      """Distribution Focal Loss (DFL) is from `Generalized Focal Loss: Learning
      Qualified and Distributed Bounding Boxes for Dense Object Detection
      <https://arxiv.org/abs/2006.04388>`_.
      Args:
          pred (Tensor): Predicted general distribution of bounding boxes
              (before softmax) with shape (N, n+1), n is the max value of the
              integral set `{0, ..., n}` in paper.
          label (Tensor): Target distance label for bounding boxes with
              shape (N,).
      Returns:
          Tensor: Loss tensor with shape (N,).
      """
      dis_left = label.cast("int64")
      dis_right = dis_left + 1
      weight_left = dis_right.cast("float32") - label
      weight_right = label - dis_left.cast("float32")
      loss = (
          F.cross_entropy(pred, dis_left, reduction="none")
          * weight_left
          + F.cross_entropy(pred, dis_right, reduction="none")
          * weight_right
      )
      return loss
  
file_path: PaddleDetection/ppdet/modeling/losses/gfocal_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register, serializable
  from ppdet.modeling import ops
label_desc: Use image node_id 2 for calling a global function with example usage: distribution_focal_loss(pred, label) and returns: loss