code: def loss_boxes(self, outputs, batch_gt_instances, indices):
      assert "pred_boxes" in outputs
      pred_boxes = outputs["pred_boxes"]
  
      target_bboxes_norm_list = [
          gt.norm_bboxes_cxcywh[J]
          for gt, (_, J) in zip(batch_gt_instances, indices)
      ]
      target_bboxes_list = [
          gt.bboxes[J]
          for gt, (_, J) in zip(batch_gt_instances, indices)
      ]
  
      pred_bboxes_list = []
      pred_bboxes_norm_list = []
      for idx in range(len(batch_gt_instances)):
          pred_bboxes_list.append(pred_boxes[idx, indices[idx][0]])
          image_size = batch_gt_instances[idx].image_size
          pred_bboxes_norm_list.append(
              pred_boxes[idx, indices[idx][0]] / image_size
          )
  
      pred_boxes_cat = torch.cat(pred_bboxes_list)
      pred_boxes_norm_cat = torch.cat(pred_bboxes_norm_list)
      target_bboxes_cat = torch.cat(target_bboxes_list)
      target_bboxes_norm_cat = torch.cat(target_bboxes_norm_list)
  
      if len(pred_boxes_cat) > 0:
          num_instances = pred_boxes_cat.shape[0]
  
          loss_bbox = (
              self.loss_bbox(
                  pred_boxes_norm_cat,
                  bbox_cxcywh_to_xyxy(target_bboxes_norm_cat),
              )
              / num_instances
          )
          loss_giou = (
              self.loss_giou(pred_boxes_cat, target_bboxes_cat)
              / num_instances
          )
      else:
          loss_bbox = pred_boxes.sum() * 0
          loss_giou = pred_boxes.sum() * 0
      return loss_bbox, loss_giou
  
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 4 for calling the DiffusionDetCriterion obj's underlying member method code with example usage: obj.loss_boxes(outputs, batch_gt_instances, indices) and returns: loss_bbox,  loss_giou