class_docstr: FCOSLoss of Consistency Regularization
code: def forward(self, student_prediction, teacher_prediction):
      stu_cls_lvl, stu_loc_lvl, stu_iou_lvl = student_prediction
      (
          tea_cls_lvl,
          tea_loc_lvl,
          tea_iou_lvl,
          self.fpn_stride,
      ) = teacher_prediction
  
      # H and W of level (used for aggregating targets)
      self.lvl_hw = []
      for t in tea_cls_lvl:
          _, _, H, W = t.shape
          self.lvl_hw.append([H, W])
  
      # levels to images
      stu_cls_img = levels_to_images(stu_cls_lvl)
      stu_loc_img = levels_to_images(stu_loc_lvl)
      stu_iou_img = levels_to_images(stu_iou_lvl)
      tea_cls_img = levels_to_images(tea_cls_lvl)
      tea_loc_img = levels_to_images(tea_loc_lvl)
      tea_iou_img = levels_to_images(tea_iou_lvl)
  
      with paddle.no_grad():
          (
              cls_mask,
              loc_mask,
              cls_targets,
              loc_targets,
              iou_targets,
          ) = multi_apply(
              self.get_targets_per_img,
              tea_cls_img,
              tea_loc_img,
              tea_iou_img,
              stu_cls_img,
              stu_loc_img,
              stu_iou_img,
          )
  
      # flatten preditction
      stu_cls = paddle.concat(stu_cls_img, axis=0)
      stu_loc = paddle.concat(stu_loc_img, axis=0)
      stu_iou = paddle.concat(stu_iou_img, axis=0)
      # flatten targets
      cls_mask = paddle.concat(cls_mask, axis=0)
      loc_mask = paddle.concat(loc_mask, axis=0)
      cls_targets = paddle.concat(cls_targets, axis=0)
      loc_targets = paddle.concat(loc_targets, axis=0)
      iou_targets = paddle.concat(iou_targets, axis=0)
  
      ### Training Weights and avg factor
      # find positives
      cls_pos_ind = paddle.nonzero(cls_mask > 0.0).squeeze(axis=-1)
      loc_pos_ind = paddle.nonzero(loc_mask > 0.0).squeeze(axis=-1)
      # cls weight
      cls_sample_weights = paddle.ones([cls_targets.shape[0]])
      cls_avg_factor = (
          paddle.max(cls_targets[cls_pos_ind], axis=-1).sum().item()
      )
      # loc weight
      loc_sample_weights = paddle.max(cls_targets[loc_pos_ind], axis=-1)
      loc_avg_factor = loc_sample_weights.sum().item()
      # iou weight
      iou_sample_weights = paddle.ones([loc_pos_ind.shape[0]])
      iou_avg_factor = loc_pos_ind.shape[0]
  
      ### unsupervised loss
      # cls loss
      loss_cls = (
          self.quality_focal_loss(
              stu_cls,
              cls_targets,
              quality=stu_iou,
              weights=cls_sample_weights,
              avg_factor=cls_avg_factor,
          )
          * self.cls_weight
      )
      # iou loss
      pos_stu_iou = paddle.squeeze(stu_iou, axis=-1)[loc_pos_ind]
      pos_iou_targets = iou_targets[loc_pos_ind]
      loss_iou = (
          F.binary_cross_entropy(
              F.sigmoid(pos_stu_iou), pos_iou_targets, reduction="none"
          )
          * iou_sample_weights
      )
      loss_iou = loss_iou.sum() / iou_avg_factor * self.iou_weight
      # box loss
      pos_stu_loc = stu_loc[loc_pos_ind]
      pos_loc_targets = loc_targets[loc_pos_ind]
  
      loss_box = self.iou_loss(
          pos_stu_loc,
          pos_loc_targets,
          weights=loc_sample_weights,
          avg_factor=loc_avg_factor,
      )
      loss_box = loss_box * self.reg_weight
  
      loss_all = {
          "loss_cls": loss_cls,
          "loss_box": loss_box,
          "loss_iou": loss_iou,
      }
      return loss_all
  
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 11 for calling the FCOSLossCR obj's underlying member method code with example usage: obj.forward(student_prediction, teacher_prediction) and returns: loss_all