class_docstr: From DETR source: https://github.com/facebookresearch/detr
  (detr/models/detr.py)
class_docstr_tok: ["From","DETR","source",":","https",":","\/\/github.com\/facebookresearch\/detr","(","detr\/models\/detr.py",")"]
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, w, h), 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",",","w",",","h",")",",","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, w, h), normalized by the image size.
      """
  
      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 = torch.nn.functional.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 typing import List, Optional, Tuple, Union
  import torch
label_desc: Use image node_id 6 for calling the SetCriterion obj's underlying member method code with example usage: obj.loss_boxes(outputs, targets, indices, num_boxes) and returns: losses