class_docstr: This class computes the loss for DETR.
  The process happens in two steps:
      1) we compute hungarian assignment between ground truth boxes and the outputs of the model
      2) we supervise each pair of matched ground-truth / prediction (supervise class and box)
class_docstr_tok: ["This","class","computes","the","loss","for","DETR",".","The","process","happens","in","two","steps",":","1",")","we","compute","hungarian","assignment","between","ground","truth","boxes","and","the","outputs","of","the","model","2",")","we","supervise","each","pair","of","matched","ground-truth","\/","prediction","(","supervise","class","and","box",")"]
docstr: Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss
  targets dicts must contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]
  The target boxes are expected in format (center_x, center_y, h, w), normalized by the image size.
docstr_tok: ["Compute","the","losses","related","to","the","bounding","boxes",",","the","L1","regression","loss","and","the","GIoU","loss","targets","dicts","must","contain","the","key","``","boxes","''","containing","a","tensor","of","dim","[","nb_target_boxes",",","4","]","The","target","boxes","are","expected","in","format","(","center_x",",","center_y",",","h",",","w",")",",","normalized","by","the","image","size","."]
code: def loss_boxes(self, outputs, targets, indices, num_boxes):
      """Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss
      targets dicts must contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]
      The target boxes are expected in format (center_x, center_y, h, w), normalized by the image size.
      """
      assert "pred_boxes" in outputs
      idx = self._get_src_permutation_idx(indices)
      src_boxes = outputs["pred_boxes"][idx]
      target_boxes = torch.cat(
          [t["boxes"][i] for t, (_, i) in zip(targets, indices)], dim=0
      )
  
      loss_bbox = F.l1_loss(src_boxes, target_boxes, reduction="none")
  
      losses = {}
      losses["loss_bbox"] = loss_bbox.sum() / num_boxes
  
      loss_giou = 1 - torch.diag(
          generalized_box_iou(
              box_cxcywh_to_xyxy(src_boxes),
              box_cxcywh_to_xyxy(target_boxes),
          )
      )
      losses["loss_giou"] = loss_giou.sum() / num_boxes
      return losses
  
imports: from collections import OrderedDict
  import torch
  from torch import nn
  from torch.jit.annotations import Dict
  from torch.nn import functional
label_desc: Use image node_id 4 for calling the SetCriterion obj's underlying member method code with example usage: obj.loss_boxes(outputs, targets, indices, num_boxes) and returns: losses