code: def loss_classes(self, class_logits, targets, indices, avg_factor):
      tgt_labels = paddle.full(
          class_logits.shape[:2], self.num_classes, dtype="int32"
      )
  
      if sum(len(v["labels"]) for v in targets) > 0:
          tgt_classes = paddle.concat(
              [
                  paddle.gather(tgt["labels"], tgt_idx, axis=0)
                  for tgt, (_, tgt_idx) in zip(targets, indices)
              ]
          )
          batch_idx, src_idx = self._get_src_permutation_idx(indices)
          for i, (batch_i, src_i) in enumerate(zip(batch_idx, src_idx)):
              tgt_labels[int(batch_i), int(src_i)] = tgt_classes[i]
  
      tgt_labels = tgt_labels.flatten(0, 1).unsqueeze(-1)
  
      tgt_labels_onehot = paddle.cast(
          tgt_labels == paddle.arange(0, self.num_classes),
          dtype="float32",
      )
      tgt_labels_onehot.stop_gradient = True
  
      src_logits = class_logits.flatten(0, 1)
  
      loss_cls = (
          F.sigmoid_focal_loss(
              src_logits,
              tgt_labels_onehot,
              alpha=self.focal_loss_alpha,
              gamma=self.focal_loss_gamma,
              reduction="sum",
          )
          / avg_factor
      )
      losses = {"loss_cls": loss_cls * self.loss_weights["loss_cls"]}
      return losses
  
file_path: PaddleDetection/ppdet/modeling/losses/queryinst_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  import paddle.nn.functional
  from ppdet.core.workspace import register
  from ppdet.modeling.losses.iou_loss import GIoULoss
  from .sparsercnn_loss import HungarianMatcher
label_desc: Use image node_id 2 for calling the QueryInstLoss obj's underlying member method code with example usage: obj.loss_classes(class_logits, targets, indices, avg_factor) and returns: losses