class_docstr: S2Anet head
  Args:
      stacked_convs (int): number of stacked_convs
      feat_in (int): input channels of feat
      feat_out (int): output channels of feat
      num_classes (int): num_classes
      anchor_strides (list): stride of anchors
      anchor_scales (list): scale of anchors
      anchor_ratios (list): ratios of anchors
      target_means (list): target_means
      target_stds (list): target_stds
      align_conv_type (str): align_conv_type ['Conv', 'AlignConv']
      align_conv_size (int): kernel size of align_conv
      use_sigmoid_cls (bool): use sigmoid_cls or not
      reg_loss_weight (list): loss weight for regression
class_docstr_tok: ["S2Anet","head","Args",":","stacked_convs","(","int",")",":","number","of","stacked_convs","feat_in","(","int",")",":","input","channels","of","feat","feat_out","(","int",")",":","output","channels","of","feat","num_classes","(","int",")",":","num_classes","anchor_strides","(","list",")",":","stride","of","anchors","anchor_scales","(","list",")",":","scale","of","anchors","anchor_ratios","(","list",")",":","ratios","of","anchors","target_means","(","list",")",":","target_means","target_stds","(","list",")",":","target_stds","align_conv_type","(","str",")",":","align_conv_type","[","'Conv","'",",","'AlignConv","'","]","align_conv_size","(","int",")",":","kernel","size","of","align_conv","use_sigmoid_cls","(","bool",")",":","use","sigmoid_cls","or","not","reg_loss_weight","(","list",")",":","loss","weight","for","regression"]
docstr: Rescale, clip and filter the bbox from the output of NMS to
  get final prediction.
  Args:
      bboxes(Tensor): bboxes [N, 10]
      bbox_num(Tensor): bbox_num
      im_shape(Tensor): [1 2]
      scale_factor(Tensor): [1 2]
  Returns:
      bbox_pred(Tensor): The output is the prediction with shape [N, 8]
                         including labels, scores and bboxes. The size of
                         bboxes are corresponding to the original image.
docstr_tok: ["Rescale",",","clip","and","filter","the","bbox","from","the","output","of","NMS","to","get","final","prediction",".","Args",":","bboxes","(","Tensor",")",":","bboxes","[","N",",","10","]","bbox_num","(","Tensor",")",":","bbox_num","im_shape","(","Tensor",")",":","[","1","2","]","scale_factor","(","Tensor",")",":","[","1","2","]","Returns",":","bbox_pred","(","Tensor",")",":","The","output","is","the","prediction","with","shape","[","N",",","8","]","including","labels",",","scores","and","bboxes",".","The","size","of","bboxes","are","corresponding","to","the","original","image","."]
code: def get_pred(self, bboxes, bbox_num, im_shape, scale_factor):
      """
      Rescale, clip and filter the bbox from the output of NMS to
      get final prediction.
      Args:
          bboxes(Tensor): bboxes [N, 10]
          bbox_num(Tensor): bbox_num
          im_shape(Tensor): [1 2]
          scale_factor(Tensor): [1 2]
      Returns:
          bbox_pred(Tensor): The output is the prediction with shape [N, 8]
                             including labels, scores and bboxes. The size of
                             bboxes are corresponding to the original image.
      """
      origin_shape = paddle.floor(im_shape / scale_factor + 0.5)
  
      origin_shape_list = []
      scale_factor_list = []
      # scale_factor: scale_y, scale_x
      for i in range(bbox_num.shape[0]):
          expand_shape = paddle.expand(
              origin_shape[i : i + 1, :], [bbox_num[i], 2]
          )
          scale_y, scale_x = scale_factor[i, 0:1], scale_factor[i, 1:2]
          scale = paddle.concat(
              [
                  scale_x,
                  scale_y,
                  scale_x,
                  scale_y,
                  scale_x,
                  scale_y,
                  scale_x,
                  scale_y,
              ]
          )
          expand_scale = paddle.expand(scale, [bbox_num[i], 8])
          origin_shape_list.append(expand_shape)
          scale_factor_list.append(expand_scale)
  
      origin_shape_list = paddle.concat(origin_shape_list)
      scale_factor_list = paddle.concat(scale_factor_list)
  
      # bboxes: [N, 10], label, score, bbox
      pred_label_score = bboxes[:, 0:2]
      pred_bbox = bboxes[:, 2:]
  
      # rescale bbox to original image
      pred_bbox = pred_bbox.reshape([-1, 8])
      scaled_bbox = pred_bbox / scale_factor_list
      origin_h = origin_shape_list[:, 0]
      origin_w = origin_shape_list[:, 1]
  
      bboxes = scaled_bbox
      zeros = paddle.zeros_like(origin_h)
      x1 = paddle.maximum(
          paddle.minimum(bboxes[:, 0], origin_w - 1), zeros
      )
      y1 = paddle.maximum(
          paddle.minimum(bboxes[:, 1], origin_h - 1), zeros
      )
      x2 = paddle.maximum(
          paddle.minimum(bboxes[:, 2], origin_w - 1), zeros
      )
      y2 = paddle.maximum(
          paddle.minimum(bboxes[:, 3], origin_h - 1), zeros
      )
      x3 = paddle.maximum(
          paddle.minimum(bboxes[:, 4], origin_w - 1), zeros
      )
      y3 = paddle.maximum(
          paddle.minimum(bboxes[:, 5], origin_h - 1), zeros
      )
      x4 = paddle.maximum(
          paddle.minimum(bboxes[:, 6], origin_w - 1), zeros
      )
      y4 = paddle.maximum(
          paddle.minimum(bboxes[:, 7], origin_h - 1), zeros
      )
      pred_bbox = paddle.stack(
          [x1, y1, x2, y2, x3, y3, x4, y4], axis=-1
      )
      pred_result = paddle.concat([pred_label_score, pred_bbox], axis=1)
      return pred_result
  
imports: import paddle
  from paddle import ParamAttr
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.initializer import Normal, Constant
  from ppdet.core.workspace import register
  from ppdet.modeling.proposal_generator.target_layer import RBoxAssigner
  from ppdet.modeling.proposal_generator.anchor_generator import S2ANetAnchorGenerator
  from ppdet.modeling.layers import AlignConv
  from ..cls_utils import _get_class_default_kwargs
  import numpy
label_desc: Use image node_id 4 for calling the S2ANetHead obj's underlying member method code with example usage: obj.get_pred(bboxes, bbox_num, im_shape, scale_factor) and returns: pred_result