class_docstr: FCOSLoss of Consistency Regularization
code: def get_targets_per_img(
      self, tea_cls, tea_loc, tea_iou, stu_cls, stu_loc, stu_iou
  ):
      ### sample selection
      # prepare datas
      tea_cls_scores = F.sigmoid(tea_cls) * F.sigmoid(tea_iou)
      class_ind = paddle.argmax(tea_cls_scores, axis=-1)
      max_vals = paddle.max(tea_cls_scores, axis=-1)
      cls_mask = paddle.zeros_like(
          max_vals
      )  # set cls valid mask: pos is 1, hard_negative and negative are 0.
      num_pos, num_hard_neg = 0, 0
  
      # mean-std selection
      # using nonzero to turn index from bool to int, because the index will be used to compose two-dim index in following.
      # using squeeze rather than reshape to avoid errors when no score is larger than thresh.
      candidate_ind = paddle.nonzero(max_vals >= 0.1).squeeze(axis=-1)
      num_candidate = candidate_ind.shape[0]
      if num_candidate > 0:
          # pos thresh = mean + std to select pos samples
          candidate_score = max_vals[candidate_ind]
          candidate_score_mean = candidate_score.mean()
          candidate_score_std = candidate_score.std()
          pos_thresh = (
              candidate_score_mean + candidate_score_std
          ).clip(max=0.4)
          # select pos
          pos_ind = paddle.nonzero(max_vals >= pos_thresh).squeeze(
              axis=-1
          )
          num_pos = pos_ind.shape[0]
          # select hard negatives as potential pos
          hard_neg_ind = (max_vals >= 0.1) & (max_vals < pos_thresh)
          hard_neg_ind = paddle.nonzero(hard_neg_ind).squeeze(axis=-1)
          num_hard_neg = hard_neg_ind.shape[0]
      # if not positive, directly select top-10 as pos.
      if num_pos == 0:
          num_pos = 10
          _, pos_ind = paddle.topk(max_vals, k=num_pos)
      cls_mask[pos_ind] = 1.0
  
      ### Consistency Regularization Training targets
      # cls targets
      pos_class_ind = class_ind[pos_ind]
      cls_targets = paddle.zeros_like(tea_cls)
      cls_targets[pos_ind, pos_class_ind] = tea_cls_scores[
          pos_ind, pos_class_ind
      ]
      # hard negative cls target
      if num_hard_neg != 0:
          cls_targets[hard_neg_ind] = tea_cls_scores[hard_neg_ind]
      # loc targets
      loc_targets = paddle.zeros_like(tea_loc)
      loc_targets[pos_ind] = tea_loc[pos_ind]
      # iou targets
      iou_targets = paddle.zeros(
          shape=[tea_iou.shape[0]], dtype=tea_iou.dtype
      )
      iou_targets[pos_ind] = F.sigmoid(
          paddle.squeeze(tea_iou, axis=-1)[pos_ind]
      )
  
      loc_mask = cls_mask.clone()
      # select potential positive from hard negatives for loc_task training
      if (num_hard_neg > 0) and self.hard_neg_mining_flag:
          results = self.hard_neg_mining(
              tea_cls,
              tea_loc,
              tea_iou,
              pos_ind,
              hard_neg_ind,
              loc_mask,
              loc_targets,
          )
          if results is not None:
              loc_mask, loc_targets = results
              loc_pos_ind = paddle.nonzero(loc_mask > 0.0).squeeze(
                  axis=-1
              )
              iou_targets[loc_pos_ind] = F.sigmoid(
                  paddle.squeeze(tea_iou, axis=-1)[loc_pos_ind]
              )
  
      return cls_mask, loc_mask, cls_targets, loc_targets, iou_targets
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register
  from ppdet.modeling import ops
  from functools import partial
label_desc: Use image node_id 10 for calling the FCOSLossCR obj's underlying member method code with example usage: obj.get_targets_per_img(tea_cls, tea_loc, tea_iou, stu_cls, stu_loc, stu_iou) and returns: cls_mask,  loc_mask,  cls_targets,  loc_targets,  iou_targets