code: def border_loss(self, f_border, l_border, l_score, l_mask):
      l_border_split, l_border_norm = paddle.tensor.split(
          l_border, num_or_sections=[4, 1], axis=1
      )
      f_border_split = f_border
      b, c, h, w = l_border_norm.shape
      l_border_norm_split = paddle.expand(
          x=l_border_norm, shape=[b, 4 * c, h, w]
      )
      b, c, h, w = l_score.shape
      l_border_score = paddle.expand(x=l_score, shape=[b, 4 * c, h, w])
      b, c, h, w = l_mask.shape
      l_border_mask = paddle.expand(x=l_mask, shape=[b, 4 * c, h, w])
      border_diff = l_border_split - f_border_split
      abs_border_diff = paddle.abs(border_diff)
      border_sign = abs_border_diff < 1.0
      border_sign = paddle.cast(border_sign, dtype="float32")
      border_sign.stop_gradient = True
      border_in_loss = (
          0.5 * abs_border_diff * abs_border_diff * border_sign
          + (abs_border_diff - 0.5) * (1.0 - border_sign)
      )
      border_out_loss = l_border_norm_split * border_in_loss
      border_loss = paddle.sum(
          border_out_loss * l_border_score * l_border_mask
      ) / (paddle.sum(l_border_score * l_border_mask) + 1e-5)
      return border_loss
  
file_path: PaddleOCR/ppocr/losses/e2e_pg_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from paddle import nn
  import paddle
  from .det_basic_loss import DiceLoss
  from ppocr.utils.e2e_utils.extract_batchsize import pre_process
label_desc: Use image node_id 2 for calling the PGLoss obj's underlying member method code with example usage: obj.border_loss(f_border, l_border, l_score, l_mask) and returns: border_loss