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: Classification loss (NLL)
  targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
docstr_tok: ["Classification","loss","(","NLL",")","targets","dicts","must","contain","the","key","``","labels","''","containing","a","tensor","of","dim","[","nb_target_boxes","]"]
code: def loss_labels(self, outputs, targets, indices):
      """Classification loss (NLL)
      targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
      """
  
      src_logits = outputs["pred_logits"]
  
      idx = self._get_src_permutation_idx(indices)
      target_classes_o = torch.cat(
          [t["labels"][J] for t, (_, J) in zip(targets, indices)]
      )
      target_classes = torch.full(
          src_logits.shape[:2],
          self.num_classes,
          dtype=torch.int64,
          device=src_logits.device,
      )
      target_classes[idx] = target_classes_o
  
      loss_ce = torch.nn.functional.cross_entropy(
          src_logits.transpose(1, 2),
          target_classes,
          self.empty_weight.to(src_logits.device),
      )
      losses = {"loss_ce": loss_ce}
      return losses
  
imports: from typing import List, Optional, Tuple, Union
  import torch
label_desc: Use image node_id 4 for calling the SetCriterion obj's underlying member method code with example usage: obj.loss_labels(outputs, targets, indices) and returns: losses