code: def loss_classification(self, outputs, batch_gt_instances, indices):
      assert "pred_logits" in outputs
      src_logits = outputs["pred_logits"]
      target_classes_list = [
          gt.labels[J]
          for gt, (_, J) in zip(batch_gt_instances, indices)
      ]
      target_classes = torch.full(
          src_logits.shape[:2],
          self.num_classes,
          dtype=torch.int64,
          device=src_logits.device,
      )
      for idx in range(len(batch_gt_instances)):
          target_classes[idx, indices[idx][0]] = target_classes_list[
              idx
          ]
  
      src_logits = src_logits.flatten(0, 1)
      target_classes = target_classes.flatten(0, 1)
      # comp focal loss.
      num_instances = max(torch.cat(target_classes_list).shape[0], 1)
      loss_cls = (
          self.loss_cls(
              src_logits,
              target_classes,
          )
          / num_instances
      )
      return loss_cls
  
imports: from typing import List, Tuple, Union
  import torch
  import torch.nn
  from mmengine.config import ConfigDict
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy, bbox_xyxy_to_cxcywh
  from mmdet.utils import ConfigType
label_desc: Use image node_id 3 for calling the DiffusionDetCriterion obj's underlying member method code with example usage: obj.loss_classification(outputs, batch_gt_instances, indices) and returns: loss_cls