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: This performs the loss computation.
  Parameters:
       outputs: dict of tensors, see the output specification of the model for
                the format
       targets: list of dicts, such that len(targets) == batch_size.
                The expected keys in each dict depends on the losses applied, see
                each loss' doc
docstr_tok: ["This","performs","the","loss","computation",".","Parameters",":","outputs",":","dict","of","tensors",",","see","the","output","specification","of","the","model","for","the","format","targets",":","list","of","dicts",",","such","that","len","(","targets",")","==","batch_size",".","The","expected","keys","in","each","dict","depends","on","the","losses","applied",",","see","each","loss","'","doc"]
code: def forward(self, outputs, targets):
      """This performs the loss computation.
      Parameters:
           outputs: dict of tensors, see the output specification of the model for
                    the format
           targets: list of dicts, such that len(targets) == batch_size.
                    The expected keys in each dict depends on the losses applied, see
                    each loss' doc
      """
      outputs_without_aux = {
          k: v for k, v in outputs.items() if k != "aux_outputs"
      }
  
      # Retrieve the matching between the outputs of the last layer and the targets
      indices = self.matcher(outputs_without_aux, targets)
  
      # Compute the average number of target boxes accross all nodes, for
      # normalization purposes
      num_boxes = sum(len(t["labels"]) for t in targets)
      num_boxes = torch.as_tensor(
          [num_boxes],
          dtype=torch.float,
          device=next(iter(outputs.values())).device,
      )
      if is_dist_initialized():
          torch.distributed.all_reduce(num_boxes)
      num_boxes = torch.clamp(
          num_boxes / get_world_size(), min=1
      ).item()
  
      # Compute all the requested losses
      losses = {}
      for loss in self.losses:
          losses.update(
              self.get_loss(loss, outputs, targets, indices, num_boxes)
          )
  
      # In case of auxiliary losses, we repeat this process with the output of each
      # intermediate layer.
      if "aux_outputs" in outputs:
          for i, aux_outputs in enumerate(outputs["aux_outputs"]):
              indices = self.matcher(aux_outputs, targets)
              for loss in self.losses:
                  kwargs = {}
                  if loss in ("labels", "labels_balanced"):
                      # Logging is enabled only for the last layer
                      kwargs = {"log": False}
                  l_dict = self.get_loss(
                      loss,
                      aux_outputs,
                      targets,
                      indices,
                      num_boxes,
                      **kwargs,
                  )
                  l_dict = {k + f"_{i}": v for k, v in l_dict.items()}
                  losses.update(l_dict)
  
      return losses
  
imports: from typing import Optional
  import torch
  import torch.nn.functional
  from mmf.models.unit.backbone import build_unit_convnet_backbone
  from mmf.models.unit.matcher import HungarianMatcher
  from mmf.models.unit.misc import NestedTensor
  from mmf.models.unit.transformer import UniTTransformer
  from mmf.utils import box_ops
  from mmf.utils.distributed import get_world_size, is_dist_initialized
  from torch import nn, Tensor
label_desc: Use image node_id 9 for calling the SetCriterion obj's underlying member method code with example usage: obj.forward(outputs, targets) and returns: losses