class_docstr: This part is partially derivated from:
  
  https://github.com/facebookresearch/detr/blob/main/models/detr.py.
class_docstr_tok: ["This","part","is","partially","derivated","from",":","https",":","\/\/github.com\/facebookresearch\/detr\/blob\/main\/models\/detr.py","."]
code: def forward(
      self,
      outputs,
      batch_gt_instances,
      batch_img_metas,
      batch_gt_instances_ignore,
  ):
      # Retrieve the matching between the outputs of
      # the last layer and the targets
      indices = self.matcher(outputs, batch_gt_instances)
      # Compute the average number of target boxes
      # across all nodes, for normalization purposes
      num_instances = sum(
          gt.labels.shape[0] for gt in batch_gt_instances
      )
      num_instances = torch.as_tensor(
          [num_instances],
          dtype=torch.float,
          device=next(iter(outputs.values())).device,
      )
      num_instances = reduce_mean(num_instances).clamp_(min=1).item()
      # Compute all the requested losses
      loss_cls = self.loss_classification(
          outputs, batch_gt_instances, indices, num_instances
      )
      (
          loss_obj,
          loss_dice,
          loss_mask,
      ) = self.loss_masks_with_iou_objectness(
          outputs, batch_gt_instances, indices, num_instances
      )
  
      return dict(
          loss_cls=loss_cls,
          loss_obj=loss_obj,
          loss_dice=loss_dice,
          loss_mask=loss_mask,
      )
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from scipy.optimize import linear_sum_assignment
  from torch.cuda.amp import autocast
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.utils import reduce_mean
label_desc: Use image node_id 6 for calling the SparseInstCriterion obj's underlying member method code with example usage: obj.forward(outputs, batch_gt_instances, batch_img_metas, batch_gt_instances_ignore) and returns: dict