class_docstr: Image pre-processor for detection tasks.
  
  Comparing with the :class:`mmengine.ImgDataPreprocessor`,
  
  1. It supports batch augmentations.
  2. It will additionally append batch_input_shape and pad_shape
  to data_samples considering the object detection task.
  
  It provides the data pre-processing as follows
  
  - Collate and move data to the target device.
  - Pad inputs to the maximum size of current batch with defined
    ``pad_value``. The padding size can be divisible by a defined
    ``pad_size_divisor``
  - Stack inputs to batch_inputs.
  - Convert inputs from bgr to rgb if the shape of input is (3, H, W).
  - Normalize image with defined std and mean.
  - Do batch augmentations during training.
  
  Args:
      mean (Sequence[Number], optional): The pixel mean of R, G, B channels.
          Defaults to None.
      std (Sequence[Number], optional): The pixel standard deviation of
          R, G, B channels. Defaults to None.
      pad_size_divisor (int): The size of padded image should be
          divisible by ``pad_size_divisor``. Defaults to 1.
      pad_value (Number): The padded pixel value. Defaults to 0.
      pad_mask (bool): Whether to pad instance masks. Defaults to False.
      mask_pad_value (int): The padded pixel value for instance masks.
          Defaults to 0.
      pad_seg (bool): Whether to pad semantic segmentation maps.
          Defaults to False.
      seg_pad_value (int): The padded pixel value for semantic
          segmentation maps. Defaults to 255.
      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 RGB.
          Defaults to False.
      boxtype2tensor (bool): Whether to convert the ``BaseBoxes`` type of
          bboxes data to ``Tensor`` type. Defaults to True.
      non_blocking (bool): Whether block current process
          when transferring data to device. Defaults to False.
      batch_augments (list[dict], optional): Batch-level augmentations
class_docstr_tok: ["Image","pre-processor","for","detection","tasks",".","Comparing","with","the",":","class",":","`","mmengine.ImgDataPreprocessor","`",",","1",".","It","supports","batch","augmentations",".","2",".","It","will","additionally","append","batch_input_shape","and","pad_shape","to","data_samples","considering","the","object","detection","task",".","It","provides","the","data","pre-processing","as","follows","-","Collate","and","move","data","to","the","target","device",".","-","Pad","inputs","to","the","maximum","size","of","current","batch","with","defined","``","pad_value","``",".","The","padding","size","can","be","divisible","by","a","defined","``","pad_size_divisor","``","-","Stack","inputs","to","batch_inputs",".","-","Convert","inputs","from","bgr","to","rgb","if","the","shape","of","input","is","(","3",",","H",",","W",")",".","-","Normalize","image","with","defined","std","and","mean",".","-","Do","batch","augmentations","during","training",".","Args",":","mean","(","Sequence","[","Number","]",",","optional",")",":","The","pixel","mean","of","R",",","G",",","B","channels",".","Defaults","to","None",".","std","(","Sequence","[","Number","]",",","optional",")",":","The","pixel","standard","deviation","of","R",",","G",",","B","channels",".","Defaults","to","None",".","pad_size_divisor","(","int",")",":","The","size","of","padded","image","should","be","divisible","by","``","pad_size_divisor","``",".","Defaults","to","1.","pad_value","(","Number",")",":","The","padded","pixel","value",".","Defaults","to","0.","pad_mask","(","bool",")",":","Whether","to","pad","instance","masks",".","Defaults","to","False",".","mask_pad_value","(","int",")",":","The","padded","pixel","value","for","instance","masks",".","Defaults","to","0.","pad_seg","(","bool",")",":","Whether","to","pad","semantic","segmentation","maps",".","Defaults","to","False",".","seg_pad_value","(","int",")",":","The","padded","pixel","value","for","semantic","segmentation","maps",".","Defaults","to","255.","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","RGB",".","Defaults","to","False",".","boxtype2tensor","(","bool",")",":","Whether","to","convert","the","``","BaseBoxes","``","type","of","bboxes","data","to","``","Tensor","``","type",".","Defaults","to","True",".","non_blocking","(","bool",")",":","Whether","block","current","process","when","transferring","data","to","device",".","Defaults","to","False",".","batch_augments","(","list","[","dict","]",",","optional",")",":","Batch-level","augmentations"]
docstr: Get the pad_shape of each image based on data and
  pad_size_divisor.
code: def _get_pad_shape(self, data: dict) -> List[tuple]:
      """Get the pad_shape of each image based on data and
      pad_size_divisor."""
      _batch_inputs = data["inputs"]
      # Process data with `pseudo_collate`.
      if is_seq_of(_batch_inputs, torch.Tensor):
          batch_pad_shape = []
          for ori_input in _batch_inputs:
              pad_h = (
                  int(
                      np.ceil(
                          ori_input.shape[1] / self.pad_size_divisor
                      )
                  )
                  * self.pad_size_divisor
              )
              pad_w = (
                  int(
                      np.ceil(
                          ori_input.shape[2] / self.pad_size_divisor
                      )
                  )
                  * self.pad_size_divisor
              )
              batch_pad_shape.append((pad_h, pad_w))
      # Process data with `default_collate`.
      elif isinstance(_batch_inputs, torch.Tensor):
          assert _batch_inputs.dim() == 4, (
              "The input of `ImgDataPreprocessor` should be a NCHW tensor "
              "or a list of tensor, but got a tensor with shape: "
              f"{_batch_inputs.shape}"
          )
          pad_h = (
              int(
                  np.ceil(
                      _batch_inputs.shape[2] / self.pad_size_divisor
                  )
              )
              * self.pad_size_divisor
          )
          pad_w = (
              int(
                  np.ceil(
                      _batch_inputs.shape[3] / self.pad_size_divisor
                  )
              )
              * self.pad_size_divisor
          )
          batch_pad_shape = [(pad_h, pad_w)] * _batch_inputs.shape[0]
      else:
          raise TypeError(
              "Output of `cast_data` should be a dict "
              "or a tuple with inputs and data_samples, but got"
              f"{type(data)}: {data}"
          )
      return batch_pad_shape
  
imports: import random
  from numbers import Number
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmengine.dist import barrier, broadcast, get_dist_info
  from mmengine.logging import MessageHub
  from mmengine.model import BaseDataPreprocessor, ImgDataPreprocessor
  from mmengine.structures import PixelData
  from mmengine.utils import is_seq_of
  from torch import Tensor
  from mmdet.models.utils import unfold_wo_center
  from mmdet.models.utils.misc import samplelist_boxtype2tensor
  from mmdet.registry import MODELS
  from mmdet.structures import DetDataSample
  from mmdet.structures.mask import BitmapMasks
  from mmdet.utils import ConfigType
label_desc: Use image node_id 3 for calling the DetDataPreprocessor obj's underlying member method code with example usage: obj._get_pad_shape(data) and returns: batch_pad_shape