class_docstr: Wrapper of a Detectron2 model. Input/output formats of this class follow
  MMDetection's convention, so a Detectron2 model can be trained and
  evaluated in MMDetection.
  
  Args:
      detector (:obj:`ConfigDict` or dict): The module config of
          Detectron2.
      bgr_to_rgb (bool): whether to convert image from BGR to RGB.
          Defaults to False.
      rgb_to_bgr (bool): whether to convert image from RGB to BGR.
          Defaults to False.
class_docstr_tok: ["Wrapper","of","a","Detectron2","model",".","Input\/output","formats","of","this","class","follow","MMDetection","'s","convention",",","so","a","Detectron2","model","can","be","trained","and","evaluated","in","MMDetection",".","Args",":","detector","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","module","config","of","Detectron2",".","bgr_to_rgb","(","bool",")",":","whether","to","convert","image","from","BGR","to","RGB",".","Defaults","to","False",".","rgb_to_bgr","(","bool",")",":","whether","to","convert","image","from","RGB","to","BGR",".","Defaults","to","False","."]
docstr: Predict results from a batch of inputs and data samples with post-
  processing.
  
  The inputs will first convert to the Detectron2 type and feed into
  D2 models. And the results will convert back to the MMDet type.
  
  Args:
      batch_inputs (Tensor): Input images of shape (N, C, H, W).
          These should usually be mean centered and std scaled.
      batch_data_samples (list[:obj:`DetDataSample`]): The batch
          data samples. It usually includes information such
          as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`.
  
  
  Returns:
      list[:obj:`DetDataSample`]: Detection results of the
      input images. Each DetDataSample usually contain
      'pred_instances'. And the ``pred_instances`` usually
      contains following keys.
  
      - scores (Tensor): Classification scores, has a shape
        (num_instance, )
      - labels (Tensor): Labels of bboxes, has a shape
        (num_instances, ).
      - bboxes (Tensor): Has a shape (num_instances, 4),
        the last dimension 4 arrange as (x1, y1, x2, y2).
docstr_tok: ["Predict","results","from","a","batch","of","inputs","and","data","samples","with","post-","processing",".","The","inputs","will","first","convert","to","the","Detectron2","type","and","feed","into","D2","models",".","And","the","results","will","convert","back","to","the","MMDet","type",".","Args",":","batch_inputs","(","Tensor",")",":","Input","images","of","shape","(","N",",","C",",","H",",","W",")",".","These","should","usually","be","mean","centered","and","std","scaled",".","batch_data_samples","(","list","[",":","obj",":","`","DetDataSample","`","]",")",":","The","batch","data","samples",".","It","usually","includes","information","such","as","`","gt_instance","`","or","`","gt_panoptic_seg","`","or","`","gt_sem_seg","`",".","Returns",":","list","[",":","obj",":","`","DetDataSample","`","]",":","Detection","results","of","the","input","images",".","Each","DetDataSample","usually","contain","'pred_instances","'",".","And","the","``","pred_instances","``","usually","contains","following","keys",".","-","scores","(","Tensor",")",":","Classification","scores",",","has","a","shape","(","num_instance",",",")","-","labels","(","Tensor",")",":","Labels","of","bboxes",",","has","a","shape","(","num_instances",",",")",".","-","bboxes","(","Tensor",")",":","Has","a","shape","(","num_instances",",","4",")",",","the","last","dimension","4","arrange","as","(","x1",",","y1",",","x2",",","y2",")","."]
code: def predict(
      self, batch_inputs: Tensor, batch_data_samples: SampleList
  ) -> SampleList:
      """Predict results from a batch of inputs and data samples with post-
      processing.
  
      The inputs will first convert to the Detectron2 type and feed into
      D2 models. And the results will convert back to the MMDet type.
  
      Args:
          batch_inputs (Tensor): Input images of shape (N, C, H, W).
              These should usually be mean centered and std scaled.
          batch_data_samples (list[:obj:`DetDataSample`]): The batch
              data samples. It usually includes information such
              as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`.
  
  
      Returns:
          list[:obj:`DetDataSample`]: Detection results of the
          input images. Each DetDataSample usually contain
          'pred_instances'. And the ``pred_instances`` usually
          contains following keys.
  
          - scores (Tensor): Classification scores, has a shape
            (num_instance, )
          - labels (Tensor): Labels of bboxes, has a shape
            (num_instances, ).
          - bboxes (Tensor): Has a shape (num_instances, 4),
            the last dimension 4 arrange as (x1, y1, x2, y2).
      """
      d2_batched_inputs = self._convert_to_d2_inputs(
          batch_inputs=batch_inputs,
          batch_data_samples=batch_data_samples,
          training=False,
      )
      # results in detectron2 has already rescale
      d2_results_list = self.d2_model(d2_batched_inputs)
      batch_data_samples = convert_d2_pred_to_datasample(
          data_samples=batch_data_samples,
          d2_results_list=d2_results_list,
      )
  
      return batch_data_samples
  
imports: from typing import Union
  from mmengine.config import ConfigDict
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import BaseBoxes
  from mmdet.structures.mask import BitmapMasks, PolygonMasks
  from mmdet.utils import ConfigType
  from .base import BaseDetector
label_desc: Use image node_id 4 for calling the Detectron2Wrapper obj's underlying member method code with example usage: obj.predict(batch_inputs, batch_data_samples) and returns: batch_data_samples