class_docstr: FCOSR Assigner, refer to https://arxiv.org/abs/2111.10780 for details
  
  1. compute normalized gaussian distribution score and refined gaussian distribution score
  2. refer to ellipse center sampling, sample points whose normalized gaussian distribution score is greater than threshold
  3. refer to multi-level sampling, assign ground truth to feature map which follows two conditions.
      i). first, the ratio between the short edge of the target and the stride of the feature map is less than 2.
      ii). second, the long edge of minimum bounding rectangle of the target is larger than the acceptance range of feature map
  4. refer to fuzzy sample label assignment, the points satisfying 2 and 3 will be assigned to the ground truth according to gaussian distribution score
docstr: Args:
      anchor_points (Tensor, float32): pre-defined anchor points, shape(1, L, 2),
              "x, y" format
      stride_tensor (Tensor, float32): stride tensor, shape (1, L, 1)
      num_anchors_list (List): num of anchors in each level
      gt_labels (Tensor, int64|int32): Label of gt_bboxes, shape(B, n, 1)
      gt_bboxes (Tensor, float32): Ground truth bboxes, shape(B, n, 4)
      gt_rboxes (Tensor, float32): Ground truth bboxes, shape(B, n, 5)
      pad_gt_mask (Tensor, float32): 1 means bbox, 0 means no bbox, shape(B, n, 1)
      bg_index (int): background index
      pred_rboxes (Tensor, float32, optional): predicted bounding boxes, shape(B, L, 5)
  Returns:
      assigned_labels (Tensor): (B, L)
      assigned_rboxes (Tensor): (B, L, 5)
      assigned_scores (Tensor): (B, L, C), if pred_rboxes is not None, then output ious
docstr_tok: ["Args",":","anchor_points","(","Tensor",",","float32",")",":","pre-defined","anchor","points",",","shape","(","1",",","L",",","2",")",",","``","x",",","y","''","format","stride_tensor","(","Tensor",",","float32",")",":","stride","tensor",",","shape","(","1",",","L",",","1",")","num_anchors_list","(","List",")",":","num","of","anchors","in","each","level","gt_labels","(","Tensor",",","int64|int32",")",":","Label","of","gt_bboxes",",","shape","(","B",",","n",",","1",")","gt_bboxes","(","Tensor",",","float32",")",":","Ground","truth","bboxes",",","shape","(","B",",","n",",","4",")","gt_rboxes","(","Tensor",",","float32",")",":","Ground","truth","bboxes",",","shape","(","B",",","n",",","5",")","pad_gt_mask","(","Tensor",",","float32",")",":","1","means","bbox",",","0","means","no","bbox",",","shape","(","B",",","n",",","1",")","bg_index","(","int",")",":","background","index","pred_rboxes","(","Tensor",",","float32",",","optional",")",":","predicted","bounding","boxes",",","shape","(","B",",","L",",","5",")","Returns",":","assigned_labels","(","Tensor",")",":","(","B",",","L",")","assigned_rboxes","(","Tensor",")",":","(","B",",","L",",","5",")","assigned_scores","(","Tensor",")",":","(","B",",","L",",","C",")",",","if","pred_rboxes","is","not","None",",","then","output","ious"]
code: def forward(
      self,
      anchor_points,
      stride_tensor,
      num_anchors_list,
      gt_labels,
      gt_bboxes,
      gt_rboxes,
      pad_gt_mask,
      bg_index,
      pred_rboxes=None,
  ):
      r"""
  
      Args:
          anchor_points (Tensor, float32): pre-defined anchor points, shape(1, L, 2),
                  "x, y" format
          stride_tensor (Tensor, float32): stride tensor, shape (1, L, 1)
          num_anchors_list (List): num of anchors in each level
          gt_labels (Tensor, int64|int32): Label of gt_bboxes, shape(B, n, 1)
          gt_bboxes (Tensor, float32): Ground truth bboxes, shape(B, n, 4)
          gt_rboxes (Tensor, float32): Ground truth bboxes, shape(B, n, 5)
          pad_gt_mask (Tensor, float32): 1 means bbox, 0 means no bbox, shape(B, n, 1)
          bg_index (int): background index
          pred_rboxes (Tensor, float32, optional): predicted bounding boxes, shape(B, L, 5)
      Returns:
          assigned_labels (Tensor): (B, L)
          assigned_rboxes (Tensor): (B, L, 5)
          assigned_scores (Tensor): (B, L, C), if pred_rboxes is not None, then output ious
      """
  
      _, num_anchors, _ = anchor_points.shape
      batch_size, num_max_boxes, _ = gt_rboxes.shape
      if num_max_boxes == 0:
          assigned_labels = paddle.full(
              [batch_size, num_anchors], bg_index, dtype=gt_labels.dtype
          )
          assigned_rboxes = paddle.zeros([batch_size, num_anchors, 5])
          assigned_scores = paddle.zeros(
              [batch_size, num_anchors, self.num_classes]
          )
          return assigned_labels, assigned_rboxes, assigned_scores
  
      # get normalized gaussian distribution score and refined distribution score
      gt_polys = box2corners(gt_rboxes)
      score, refined_score = self.get_gaussian_distribution_score(
          anchor_points, gt_rboxes, gt_polys
      )
      inside_mask = self.get_rotated_inside_mask(
          anchor_points, gt_polys, score
      )
      regress_ranges = []
      for num, bound in zip(num_anchors_list, self.boundary):
          regress_ranges.append(bound.tile((1, num, 1)))
      regress_ranges = paddle.concat(regress_ranges, axis=1)
      regress_mask = self.get_inside_range_mask(
          anchor_points,
          gt_bboxes,
          gt_rboxes,
          stride_tensor,
          regress_ranges,
      )
      # [B, n, L]
      mask_positive = inside_mask * regress_mask * pad_gt_mask
      refined_score = refined_score * mask_positive - (
          1.0 - mask_positive
      )
  
      argmax_refined_score = refined_score.argmax(axis=-2)
      max_refined_score = refined_score.max(axis=-2)
      assigned_gt_index = argmax_refined_score
  
      # assigned target
      batch_ind = paddle.arange(
          end=batch_size, dtype=gt_labels.dtype
      ).unsqueeze(-1)
      assigned_gt_index = assigned_gt_index + batch_ind * num_max_boxes
      assigned_labels = paddle.gather(
          gt_labels.flatten(), assigned_gt_index.flatten(), axis=0
      )
      assigned_labels = assigned_labels.reshape(
          [batch_size, num_anchors]
      )
      assigned_labels = paddle.where(
          max_refined_score > 0,
          assigned_labels,
          paddle.full_like(assigned_labels, bg_index),
      )
  
      assigned_rboxes = paddle.gather(
          gt_rboxes.reshape([-1, 5]),
          assigned_gt_index.flatten(),
          axis=0,
      )
      assigned_rboxes = assigned_rboxes.reshape(
          [batch_size, num_anchors, 5]
      )
  
      assigned_scores = F.one_hot(assigned_labels, self.num_classes + 1)
      ind = list(range(self.num_classes + 1))
      ind.remove(bg_index)
      assigned_scores = paddle.index_select(
          assigned_scores, paddle.to_tensor(ind), axis=-1
      )
  
      if self.score_type == "gaussian":
          selected_scores = paddle_gather(
              score, 1, argmax_refined_score.unsqueeze(-2)
          ).squeeze(-2)
          assigned_scores = assigned_scores * selected_scores.unsqueeze(
              -1
          )
      elif self.score_type == "iou":
          assert (
              pred_rboxes is not None
          ), "If score type is iou, pred_rboxes should not be None"
          from ext_op import matched_rbox_iou
  
          b, l = pred_rboxes.shape[:2]
          iou_score = matched_rbox_iou(
              pred_rboxes.reshape((-1, 5)),
              assigned_rboxes.reshape((-1, 5)),
          ).reshape((b, l, 1))
          assigned_scores = assigned_scores * iou_score
  
      return assigned_labels, assigned_rboxes, assigned_scores
  
file_path: PaddleDetection/ppdet/modeling/assigners/fcosr_assigner.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
  from ppdet.modeling.rbox_utils import box2corners, check_points_in_polys, paddle_gather
label_desc: Use image node_id 5 for calling the FCOSRAssigner obj's underlying member method code with example usage: obj.forward(anchor_points, stride_tensor, num_anchors_list, gt_labels, gt_bboxes, gt_rboxes, pad_gt_mask, bg_index, pred_rboxes) and returns: assigned_labels,  assigned_rboxes,  assigned_scores, assigned_labels,  assigned_rboxes,  assigned_scores