docstr: Forward function.
  
  Args:
      mlvl_feats (tuple[Tensor]): Features from the upstream
          network, each is a 4D-tensor with shape
          (N, C, H, W).
      img_metas (list[dict]): List of image information.
  
  Returns:
      all_cls_scores (Tensor): Outputs from the classification head,                 shape [nb_dec, bs, num_query, cls_out_channels]. Note                 cls_out_channels should includes background.
      all_bbox_preds (Tensor): Sigmoid outputs from the regression                 head with normalized coordinate format (cx, cy, w, h).                 Shape [nb_dec, bs, num_query, 4].
      enc_outputs_class (Tensor): The score of each point on encode                 feature map, has shape (N, h*w, num_class). Only when                 as_two_stage is True it would be returned, otherwise                 `None` would be returned.
      enc_outputs_coord (Tensor): The proposal generate from the                 encode feature map, has shape (N, h*w, 4). Only when                 as_two_stage is True it would be returned, otherwise                 `None` would be returned.
docstr_tok: ["Forward","function",".","Args",":","mlvl_feats","(","tuple","[","Tensor","]",")",":","Features","from","the","upstream","network",",","each","is","a","4D-tensor","with","shape","(","N",",","C",",","H",",","W",")",".","img_metas","(","list","[","dict","]",")",":","List","of","image","information",".","Returns",":","all_cls_scores","(","Tensor",")",":","Outputs","from","the","classification","head",",","shape","[","nb_dec",",","bs",",","num_query",",","cls_out_channels","]",".","Note","cls_out_channels","should","includes","background",".","all_bbox_preds","(","Tensor",")",":","Sigmoid","outputs","from","the","regression","head","with","normalized","coordinate","format","(","cx",",","cy",",","w",",","h",")",".","Shape","[","nb_dec",",","bs",",","num_query",",","4","]",".","enc_outputs_class","(","Tensor",")",":","The","score","of","each","point","on","encode","feature","map",",","has","shape","(","N",",","h","*","w",",","num_class",")",".","Only","when","as_two_stage","is","True","it","would","be","returned",",","otherwise","`","None","`","would","be","returned",".","enc_outputs_coord","(","Tensor",")",":","The","proposal","generate","from","the","encode","feature","map",",","has","shape","(","N",",","h","*","w",",","4",")",".","Only","when","as_two_stage","is","True","it","would","be","returned",",","otherwise","`","None","`","would","be","returned","."]
code: def forward_aux(self, mlvl_feats, img_metas, aux_targets, head_idx):
      """Forward function.
  
          Args:
              mlvl_feats (tuple[Tensor]): Features from the upstream
                  network, each is a 4D-tensor with shape
                  (N, C, H, W).
              img_metas (list[dict]): List of image information.
  
          Returns:
              all_cls_scores (Tensor): Outputs from the classification head, \
                  shape [nb_dec, bs, num_query, cls_out_channels]. Note \
                  cls_out_channels should includes background.
              all_bbox_preds (Tensor): Sigmoid outputs from the regression \
                  head with normalized coordinate format (cx, cy, w, h). \
                  Shape [nb_dec, bs, num_query, 4].
              enc_outputs_class (Tensor): The score of each point on encode \
                  feature map, has shape (N, h*w, num_class). Only when \
                  as_two_stage is True it would be returned, otherwise \
                  `None` would be returned.
              enc_outputs_coord (Tensor): The proposal generate from the \
                  encode feature map, has shape (N, h*w, 4). Only when \
                  as_two_stage is True it would be returned, otherwise \
                  `None` would be returned.
          """
      (
          aux_coords,
          aux_labels,
          aux_targets,
          aux_label_weights,
          aux_bbox_weights,
          aux_feats,
          attn_masks,
      ) = aux_targets
      batch_size = mlvl_feats[0].size(0)
      input_img_h, input_img_w = img_metas[0]["batch_input_shape"]
      img_masks = mlvl_feats[0].new_ones(
          (batch_size, input_img_h, input_img_w)
      )
      for img_id in range(batch_size):
          img_h, img_w = img_metas[img_id]["img_shape"]
          img_masks[img_id, :img_h, :img_w] = 0
  
      mlvl_masks = []
      mlvl_positional_encodings = []
      for feat in mlvl_feats:
          mlvl_masks.append(
              F.interpolate(img_masks[None], size=feat.shape[-2:])
              .to(torch.bool)
              .squeeze(0)
          )
          mlvl_positional_encodings.append(
              self.positional_encoding(mlvl_masks[-1])
          )
  
      query_embeds = None
      hs, inter_references = self.transformer.forward_aux(
          mlvl_feats,
          mlvl_masks,
          query_embeds,
          mlvl_positional_encodings,
          aux_coords,
          pos_feats=aux_feats,
          reg_branches=self.reg_branches
          if self.with_box_refine
          else None,
          cls_branches=self.cls_branches if self.as_two_stage else None,
          return_encoder_output=True,
          attn_masks=attn_masks,
          head_idx=head_idx,
      )
  
      hs = hs.permute(0, 2, 1, 3)
      outputs_classes = []
      outputs_coords = []
  
      for lvl in range(hs.shape[0]):
          reference = inter_references[lvl]
          reference = inverse_sigmoid(reference, eps=1e-3)
          outputs_class = self.cls_branches[lvl](hs[lvl])
          tmp = self.reg_branches[lvl](hs[lvl])
          if reference.shape[-1] == 4:
              tmp += reference
          else:
              assert reference.shape[-1] == 2
              tmp[..., :2] += reference
          outputs_coord = tmp.sigmoid()
          outputs_classes.append(outputs_class)
          outputs_coords.append(outputs_coord)
  
      outputs_classes = torch.stack(outputs_classes)
      outputs_coords = torch.stack(outputs_coords)
  
      return outputs_classes, outputs_coords, None, None
  
imports: import copy
  from typing import List
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Linear
  from mmcv.ops import batched_nms
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models import DINOHead
  from mmdet.models.layers import CdnQueryGenerator
  from mmdet.models.layers.transformer import inverse_sigmoid
  from mmdet.models.utils import multi_apply
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy, bbox_overlaps, bbox_xyxy_to_cxcywh
  from mmdet.utils import InstanceList, reduce_mean
label_desc: Use image node_id 9 for calling the CoDINOHead obj's underlying member method code with example usage: obj.forward_aux(mlvl_feats, img_metas, aux_targets, head_idx) and returns: outputs_classes,  outputs_coords,  None,  None