class_docstr: Trident roi head.
  
  Args:
      num_branch (int): Number of branches in TridentNet.
      test_branch_idx (int): In inference, all 3 branches will be used
          if `test_branch_idx==-1`, otherwise only branch with index
          `test_branch_idx` will be used.
docstr: Merge bbox predictions of each branch.
  
  Args:
      trident_results (List[:obj:`InstanceData`]): A list of InstanceData
          predicted from every branch.
  
  Returns:
      :obj:`InstanceData`: merged InstanceData.
docstr_tok: ["Merge","bbox","predictions","of","each","branch",".","Args",":","trident_results","(","List","[",":","obj",":","`","InstanceData","`","]",")",":","A","list","of","InstanceData","predicted","from","every","branch",".","Returns",":",":","obj",":","`","InstanceData","`",":","merged","InstanceData","."]
code: def merge_trident_bboxes(
      self, trident_results: InstanceList
  ) -> InstanceData:
      """Merge bbox predictions of each branch.
  
      Args:
          trident_results (List[:obj:`InstanceData`]): A list of InstanceData
              predicted from every branch.
  
      Returns:
          :obj:`InstanceData`: merged InstanceData.
      """
      bboxes = torch.cat([res.bboxes for res in trident_results])
      scores = torch.cat([res.scores for res in trident_results])
      labels = torch.cat([res.labels for res in trident_results])
  
      nms_cfg = self.test_cfg["nms"]
      results = InstanceData()
      if bboxes.numel() == 0:
          results.bboxes = bboxes
          results.scores = scores
          results.labels = labels
      else:
          det_bboxes, keep = batched_nms(
              bboxes, scores, labels, nms_cfg
          )
          results.bboxes = det_bboxes[:, :-1]
          results.scores = det_bboxes[:, -1]
          results.labels = labels[keep]
  
      if self.test_cfg["max_per_img"] > 0:
          results = results[: self.test_cfg["max_per_img"]]
      return results
  
file_path: mmdetection/mmdet/models/roi_heads/trident_roi_head.py
imports: from typing import Tuple
  import torch
  from mmcv.ops import batched_nms
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import InstanceList
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 2 for calling the TridentRoIHead obj's underlying member method code with example usage: obj.merge_trident_bboxes(trident_results) and returns: results