class_docstr: This class computes an assignment between the targets and the predictions of the
  network
  
  For efficiency reasons, the targets don't include the no_object. Because of this,
  in general, there are more predictions than targets. In this case, we do a 1-to-1
  matching of the best predictions, while the others are un-matched (and thus treated
  as non-objects).
docstr: Performs the matching
  
  Params:
      outputs: This is a dict that contains at least these entries:
           "pred_logits": Tensor of dim [batch_size, num_queries, num_classes]
              with the classification logits
           "pred_boxes": Tensor of dim [batch_size, num_queries, 4] with the
              predicted box coordinates
  
      targets: This is a list of targets (len(targets) = batch_size), where each
              target is a dict containing:
           "labels": Tensor of dim [num_target_boxes] (where num_target_boxes is
              the number of ground-truth objects in the target) containing the
              class labels
           "boxes": Tensor of dim [num_target_boxes, 4] containing the target box
              coordinates
  
  Returns:
      A list of size batch_size, containing tuples of (index_i, index_j) where:
          - index_i is the indices of the selected predictions (in order)
          - index_j is the indices of the corresponding selected targets (in
            order)
      For each batch element, it holds:
          len(index_i) = len(index_j) = min(num_queries, num_target_boxes)
code: def forward(
      self, outputs: Dict[str, Tensor], targets: List[Dict[str, Tensor]]
  ):
      """Performs the matching
  
      Params:
          outputs: This is a dict that contains at least these entries:
               "pred_logits": Tensor of dim [batch_size, num_queries, num_classes]
                  with the classification logits
               "pred_boxes": Tensor of dim [batch_size, num_queries, 4] with the
                  predicted box coordinates
  
          targets: This is a list of targets (len(targets) = batch_size), where each
                  target is a dict containing:
               "labels": Tensor of dim [num_target_boxes] (where num_target_boxes is
                  the number of ground-truth objects in the target) containing the
                  class labels
               "boxes": Tensor of dim [num_target_boxes, 4] containing the target box
                  coordinates
  
      Returns:
          A list of size batch_size, containing tuples of (index_i, index_j) where:
              - index_i is the indices of the selected predictions (in order)
              - index_j is the indices of the corresponding selected targets (in
                order)
          For each batch element, it holds:
              len(index_i) = len(index_j) = min(num_queries, num_target_boxes)
      """
      bs, num_queries = outputs["pred_logits"].shape[:2]
  
      # We flatten to compute the cost matrices in a batch
      out_prob = self.norm(
          outputs["pred_logits"].flatten(0, 1)
      )  # [batch_size * num_queries, num_classes]
      out_bbox = outputs["pred_boxes"].flatten(
          0, 1
      )  # [batch_size * num_queries, 4]
  
      # Also concat the target labels and boxes
      tgt_ids = torch.cat([v["labels"] for v in targets])
      tgt_bbox = torch.cat([v["boxes"] for v in targets])
  
      # Compute the classification cost. Contrary to the loss, we don't use the NLL,
      # but approximate it in 1 - proba[target class].
      # The 1 is a constant that doesn't change the matching, it can be omitted.
      cost_class = -out_prob[:, tgt_ids]
  
      # Compute the L1 cost between boxes
      cost_bbox = torch.cdist(out_bbox, tgt_bbox, p=1)
  
      # Compute the giou cost betwen boxes
      cost_giou = -generalized_box_iou(
          box_cxcywh_to_xyxy(out_bbox).float(),
          box_cxcywh_to_xyxy(tgt_bbox),
      )
  
      # Final cost matrix
      C = (
          self.cost_bbox * cost_bbox
          + self.cost_class * cost_class
          + self.cost_giou * cost_giou
      )
      C = C.view(bs, num_queries, -1).cpu()
  
      sizes = [len(v["boxes"]) for v in targets]
      indices = [
          linear_sum_assignment(c[i])
          for i, c in enumerate(C.split(sizes, -1))
      ]
      return [
          (
              torch.as_tensor(i, dtype=torch.int64),
              torch.as_tensor(j, dtype=torch.int64),
          )
          for i, j in indices
      ]
  
file_path: mmf/mmf/models/unit/matcher.py
imports: from typing import Dict, List
  import torch
  from mmf.utils.box_ops import box_cxcywh_to_xyxy, generalized_box_iou
  from scipy.optimize import linear_sum_assignment
  from torch import nn, Tensor
label_desc: Use image node_id 2 for calling the HungarianMatcher obj's underlying member method code with example usage: obj.forward(outputs, targets) and returns: unknown