code: def forward(self, student_head_outs, teacher_head_outs, train_cfg):
      # for semi-det distill
      (
          student_logits,
          student_deltas,
          student_quality,
      ) = student_head_outs
      (
          teacher_logits,
          teacher_deltas,
          teacher_quality,
      ) = teacher_head_outs
      nc = student_logits[0].shape[1]
  
      student_logits = paddle.concat(
          [
              _.transpose([0, 2, 3, 1]).reshape([-1, nc])
              for _ in student_logits
          ],
          axis=0,
      )
      teacher_logits = paddle.concat(
          [
              _.transpose([0, 2, 3, 1]).reshape([-1, nc])
              for _ in teacher_logits
          ],
          axis=0,
      )
  
      student_deltas = paddle.concat(
          [
              _.transpose([0, 2, 3, 1]).reshape([-1, 4])
              for _ in student_deltas
          ],
          axis=0,
      )
      teacher_deltas = paddle.concat(
          [
              _.transpose([0, 2, 3, 1]).reshape([-1, 4])
              for _ in teacher_deltas
          ],
          axis=0,
      )
  
      student_quality = paddle.concat(
          [
              _.transpose([0, 2, 3, 1]).reshape([-1, 1])
              for _ in student_quality
          ],
          axis=0,
      )
      teacher_quality = paddle.concat(
          [
              _.transpose([0, 2, 3, 1]).reshape([-1, 1])
              for _ in teacher_quality
          ],
          axis=0,
      )
  
      ratio = train_cfg.get("ratio", 0.01)
      with paddle.no_grad():
          # Region Selection
          count_num = int(teacher_logits.shape[0] * ratio)
          teacher_probs = F.sigmoid(teacher_logits)
          max_vals = paddle.max(teacher_probs, 1)
          sorted_vals, sorted_inds = paddle.topk(
              max_vals, teacher_logits.shape[0]
          )
          mask = paddle.zeros_like(max_vals)
          mask[sorted_inds[:count_num]] = 1.0
          fg_num = sorted_vals[:count_num].sum()
          b_mask = mask > 0
  
      # distill_loss_cls
      loss_logits = (
          QFLv2(
              F.sigmoid(student_logits),
              teacher_probs,
              weight=mask,
              reduction="sum",
          )
          / fg_num
      )
  
      # distill_loss_box
      inputs = paddle.concat(
          (
              -student_deltas[b_mask][..., :2],
              student_deltas[b_mask][..., 2:],
          ),
          axis=-1,
      )
      targets = paddle.concat(
          (
              -teacher_deltas[b_mask][..., :2],
              teacher_deltas[b_mask][..., 2:],
          ),
          axis=-1,
      )
      iou_loss = GIoULoss(reduction="mean")
      loss_deltas = iou_loss(inputs, targets)
  
      # distill_loss_quality
      loss_quality = F.binary_cross_entropy(
          F.sigmoid(student_quality[b_mask]),
          F.sigmoid(teacher_quality[b_mask]),
          reduction="mean",
      )
  
      return {
          "distill_loss_cls": loss_logits,
          "distill_loss_box": loss_deltas,
          "distill_loss_quality": loss_quality,
          "fg_sum": fg_num,
      }
  
file_path: PaddleDetection/ppdet/modeling/ssod/losses.py
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.losses.iou_loss import GIoULoss
  from .utils import QFLv2
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 2 for calling the SSODFCOSLoss obj's underlying member method code with example usage: obj.forward(student_head_outs, teacher_head_outs, train_cfg) and returns: dict