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: import torch
  import torch.nn.functional
  from torch import nn
  from util import box_ops
  from util.misc import NestedTensor, nested_tensor_from_tensor_list, accuracy, get_world_size, interpolate, is_dist_avail_and_initialized
  from .backbone import build_backbone
  from .matcher import build_matcher
  from .segmentation import DETRsegm, PostProcessPanoptic, PostProcessSegm, dice_loss, sigmoid_focal_loss
  from .transformer import build_transformer
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