class_docstr: Merge augmented detection results, only bboxes corresponding score under
  flipping and multi-scale resizing can be processed now.
  
  Examples:
      >>> tta_model = dict(
      >>>     type='DetTTAModel',
      >>>     tta_cfg=dict(nms=dict(
      >>>                     type='nms',
      >>>                     iou_threshold=0.5),
      >>>                     max_per_img=100))
      >>>
      >>> tta_pipeline = [
      >>>     dict(type='LoadImageFromFile',
      >>>          backend_args=None),
      >>>     dict(
      >>>         type='TestTimeAug',
      >>>         transforms=[[
      >>>             dict(type='Resize',
      >>>                  scale=(1333, 800),
      >>>                  keep_ratio=True),
      >>>         ], [
      >>>             dict(type='RandomFlip', prob=1.),
      >>>             dict(type='RandomFlip', prob=0.)
      >>>         ], [
      >>>             dict(
      >>>                 type='PackDetInputs',
      >>>                 meta_keys=('img_id', 'img_path', 'ori_shape',
      >>>                         'img_shape', 'scale_factor', 'flip',
      >>>                         'flip_direction'))
      >>>         ]])]
class_docstr_tok: ["Merge","augmented","detection","results",",","only","bboxes","corresponding","score","under","flipping","and","multi-scale","resizing","can","be","processed","now",".","Examples",":",">",">",">","tta_model","=","dict","(",">",">",">","type='DetTTAModel","'",",",">",">",">","tta_cfg=dict","(","nms=dict","(",">",">",">","type='nms","'",",",">",">",">","iou_threshold=0.5",")",",",">",">",">","max_per_img=100",")",")",">",">",">",">",">",">","tta_pipeline","=","[",">",">",">","dict","(","type='LoadImageFromFile","'",",",">",">",">","backend_args=None",")",",",">",">",">","dict","(",">",">",">","type='TestTimeAug","'",",",">",">",">","transforms=","[","[",">",">",">","dict","(","type='Resize","'",",",">",">",">","scale=","(","1333",",","800",")",",",">",">",">","keep_ratio=True",")",",",">",">",">","]",",","[",">",">",">","dict","(","type='RandomFlip","'",",","prob=1",".",")",",",">",">",">","dict","(","type='RandomFlip","'",",","prob=0",".",")",">",">",">","]",",","[",">",">",">","dict","(",">",">",">","type='PackDetInputs","'",",",">",">",">","meta_keys=","(","'img_id","'",",","'img_path","'",",","'ori_shape","'",",",">",">",">","'img_shape","'",",","'scale_factor","'",",","'flip","'",",",">",">",">","'flip_direction","'",")",")",">",">",">","]","]",")","]"]
docstr: Merge augmented detection bboxes and scores.
  
  Args:
      aug_bboxes (list[Tensor]): shape (n, 4*#class)
      aug_scores (list[Tensor] or None): shape (n, #class)
  Returns:
      tuple[Tensor]: ``bboxes`` with shape (n,4), where
      4 represent (tl_x, tl_y, br_x, br_y)
      and ``scores`` with shape (n,).
docstr_tok: ["Merge","augmented","detection","bboxes","and","scores",".","Args",":","aug_bboxes","(","list","[","Tensor","]",")",":","shape","(","n",",","4","*","#","class",")","aug_scores","(","list","[","Tensor","]","or","None",")",":","shape","(","n",",","#","class",")","Returns",":","tuple","[","Tensor","]",":","``","bboxes","``","with","shape","(","n,4",")",",","where","4","represent","(","tl_x",",","tl_y",",","br_x",",","br_y",")","and","``","scores","``","with","shape","(","n",",",")","."]
code: def merge_aug_bboxes(
      self,
      aug_bboxes: List[Tensor],
      aug_scores: List[Tensor],
      img_metas: List[str],
  ) -> Tuple[Tensor, Tensor]:
      """Merge augmented detection bboxes and scores.
  
      Args:
          aug_bboxes (list[Tensor]): shape (n, 4*#class)
          aug_scores (list[Tensor] or None): shape (n, #class)
      Returns:
          tuple[Tensor]: ``bboxes`` with shape (n,4), where
          4 represent (tl_x, tl_y, br_x, br_y)
          and ``scores`` with shape (n,).
      """
      recovered_bboxes = []
      for bboxes, img_info in zip(aug_bboxes, img_metas):
          ori_shape = img_info["ori_shape"]
          flip = img_info["flip"]
          flip_direction = img_info["flip_direction"]
          if flip:
              bboxes = bbox_flip(
                  bboxes=bboxes,
                  img_shape=ori_shape,
                  direction=flip_direction,
              )
          recovered_bboxes.append(bboxes)
      bboxes = torch.cat(recovered_bboxes, dim=0)
      if aug_scores is None:
          return bboxes
      else:
          scores = torch.cat(aug_scores, dim=0)
          return bboxes, scores
  
file_path: mmdetection/mmdet/models/test_time_augs/det_tta.py
imports: from typing import List, Tuple
  import torch
  from mmcv.ops import batched_nms
  from mmengine.model import BaseTTAModel
  from mmengine.registry import MODELS
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.structures import DetDataSample
  from mmdet.structures.bbox import bbox_flip
label_desc: Use image node_id 2 for calling the DetTTAModel obj's underlying member method code with example usage: obj.merge_aug_bboxes(aug_bboxes, aug_scores, img_metas) and returns: bboxes, bboxes,  scores