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 cardinality error, ie the absolute error in the number of predicted non-empty boxes
  This is not really a loss, it is intended for logging purposes only. It doesn't propagate gradients
docstr_tok: ["Compute","the","cardinality","error",",","ie","the","absolute","error","in","the","number","of","predicted","non-empty","boxes","This","is","not","really","a","loss",",","it","is","intended","for","logging","purposes","only",".","It","does","n't","propagate","gradients"]
code: def loss_cardinality(self, outputs, targets, indices, num_boxes):
      """Compute the cardinality error, ie the absolute error in the number of predicted non-empty boxes
      This is not really a loss, it is intended for logging purposes only. It doesn't propagate gradients
      """
      pred_logits = outputs["pred_logits"]
      device = pred_logits.device
      tgt_lengths = torch.as_tensor(
          [len(v["labels"]) for v in targets], device=device
      )
      # Count the number of predictions that are NOT "no-object" (which is the last class)
      card_pred = (
          pred_logits.argmax(-1) != pred_logits.shape[-1] - 1
      ).sum(1)
      card_err = F.l1_loss(card_pred.float(), tgt_lengths.float())
      losses = {"cardinality_error": card_err}
      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 3 for calling the SetCriterion obj's underlying member method code with example usage: obj.loss_cardinality(outputs, targets, indices, num_boxes) and returns: losses