code: def gt2yolotarget(
      gt_bbox,
      gt_class,
      gt_score,
      anchors,
      mask,
      num_classes,
      size,
      stride,
  ):
      grid_h, grid_w = size
      h, w = grid_h * stride, grid_w * stride
      an_hw = np.array(anchors) / np.array([[w, h]])
      target = np.zeros(
          (len(mask), 6 + num_classes, grid_h, grid_w), dtype=np.float32
      )
      for b in range(gt_bbox.shape[0]):
          gx, gy, gw, gh = gt_bbox[b, :]
          cls = gt_class[b]
          score = gt_score[b]
          if gw <= 0.0 or gh <= 0.0 or score <= 0.0:
              continue
  
          # find best match anchor index
          best_iou = 0.0
          best_idx = -1
          for an_idx in range(an_hw.shape[0]):
              iou = jaccard_overlap(
                  [0.0, 0.0, gw, gh],
                  [0.0, 0.0, an_hw[an_idx, 0], an_hw[an_idx, 1]],
              )
              if iou > best_iou:
                  best_iou = iou
                  best_idx = an_idx
  
          gi = int(gx * grid_w)
          gj = int(gy * grid_h)
  
          # gtbox should be regresed in this layes if best match
          # anchor index in anchor mask of this layer
          if best_idx in mask:
              best_n = mask.index(best_idx)
  
              # x, y, w, h, scale
              target[best_n, 0, gj, gi] = gx * grid_w - gi
              target[best_n, 1, gj, gi] = gy * grid_h - gj
              target[best_n, 2, gj, gi] = np.log(
                  gw * w / anchors[best_idx][0]
              )
              target[best_n, 3, gj, gi] = np.log(
                  gh * h / anchors[best_idx][1]
              )
              target[best_n, 4, gj, gi] = 2.0 - gw * gh
  
              # objectness record gt_score
              # if target[best_n, 5, gj, gi] > 0:
              #     print('find 1 duplicate')
              target[best_n, 5, gj, gi] = score
  
              # classification
              target[best_n, 6 + cls, gj, gi] = 1.0
  
      return target
  
imports: from __future__ import division
  import unittest
  import paddle
  import paddle.nn.functional
  import os
  import sys
  from ppdet.modeling.losses import YOLOv3Loss
  from ppdet.data.transform.op_helper import jaccard_overlap
  from ppdet.modeling.bbox_utils import iou_similarity
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: gt2yolotarget(gt_bbox, gt_class, gt_score, anchors, mask, num_classes, size, stride) and returns: target