class_docstr: Image pre-processor for classification tasks.
  
  Comparing with the :class:`mmengine.model.ImgDataPreprocessor`,
  
  1. It won't do normalization if ``mean`` is not specified.
  2. It does normalization and color space conversion after stacking batch.
  3. It supports batch augmentations like mixup and cutmix.
  
  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 like Mixup and Cutmix 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.
      to_rgb (bool): whether to convert image from BGR to RGB.
          Defaults to False.
      to_onehot (bool): Whether to generate one-hot format gt-labels and set
          to data samples. Defaults to False.
      num_classes (int, optional): The number of classes. Defaults to None.
      batch_augments (dict, optional): The batch augmentations settings,
          including "augments" and "probs". For more details, see
          :class:`mmpretrain.models.RandomBatchAugment`.
class_docstr_tok: ["Image","pre-processor","for","classification","tasks",".","Comparing","with","the",":","class",":","`","mmengine.model.ImgDataPreprocessor","`",",","1",".","It","wo","n't","do","normalization","if","``","mean","``","is","not","specified",".","2",".","It","does","normalization","and","color","space","conversion","after","stacking","batch",".","3",".","It","supports","batch","augmentations","like","mixup","and","cutmix",".","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","like","Mixup","and","Cutmix","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.","to_rgb","(","bool",")",":","whether","to","convert","image","from","BGR","to","RGB",".","Defaults","to","False",".","to_onehot","(","bool",")",":","Whether","to","generate","one-hot","format","gt-labels","and","set","to","data","samples",".","Defaults","to","False",".","num_classes","(","int",",","optional",")",":","The","number","of","classes",".","Defaults","to","None",".","batch_augments","(","dict",",","optional",")",":","The","batch","augmentations","settings",",","including","``","augments","''","and","``","probs","''",".","For","more","details",",","see",":","class",":","`","mmpretrain.models.RandomBatchAugment","`","."]
code: def __init__(
      self,
      mean: Sequence[Number] = None,
      std: Sequence[Number] = None,
      pad_size_divisor: int = 1,
      pad_value: Number = 0,
      to_rgb: bool = False,
      to_onehot: bool = False,
      num_classes: Optional[int] = None,
      batch_augments: Optional[dict] = None,
  ):
      if mmpretrain is None:
          raise RuntimeError(
              'Please run "pip install openmim" and '
              'run "mim install mmpretrain" to '
              "install mmpretrain first."
          )
      super().__init__()
      self.pad_size_divisor = pad_size_divisor
      self.pad_value = pad_value
      self.to_rgb = to_rgb
      self.to_onehot = to_onehot
      self.num_classes = num_classes
  
      if mean is not None:
          assert std is not None, (
              "To enable the normalization in "
              "preprocessing, please specify both `mean` and `std`."
          )
          # Enable the normalization in preprocessing.
          self._enable_normalize = True
          self.register_buffer(
              "mean", torch.tensor(mean).view(-1, 1, 1), False
          )
          self.register_buffer(
              "std", torch.tensor(std).view(-1, 1, 1), False
          )
      else:
          self._enable_normalize = False
  
      if batch_augments is not None:
          self.batch_augments = RandomBatchAugment(**batch_augments)
          if not self.to_onehot:
              from mmengine.logging import MMLogger
  
              MMLogger.get_current_instance().info(
                  "Because batch augmentations are enabled, the data "
                  "preprocessor automatically enables the `to_onehot` "
                  "option to generate one-hot format labels."
              )
              self.to_onehot = True
      else:
          self.batch_augments = None
  
file_path: mmdetection/mmdet/models/data_preprocessors/reid_data_preprocessor.py
imports: import math
  from numbers import Number
  from typing import Optional, Sequence
  import torch
  import torch.nn.functional
  from mmengine.model import BaseDataPreprocessor, stack_batch
  from mmdet.registry import MODELS
label_desc: Use image node_id 1 to create a new ReIDDataPreprocessor object from inherited base classes: BaseDataPreprocessor with example: obj = ReIDDataPreprocessor(mean, std, pad_size_divisor, pad_value, to_rgb, to_onehot, num_classes, batch_augments)