class_docstr: A Pytorch DataSet class to process a multimodal pd.DataFrame. It first uses a preprocessor to
  produce model-agnostic features. Then, each processor prepares customized data for one modality
  per model. For code simplicity, here we treat ground-truth label as one modality. This class is
  independent of specific data modalities and models.
class_docstr_tok: ["A","Pytorch","DataSet","class","to","process","a","multimodal","pd.DataFrame",".","It","first","uses","a","preprocessor","to","produce","model-agnostic","features",".","Then",",","each","processor","prepares","customized","data","for","one","modality","per","model",".","For","code","simplicity",",","here","we","treat","ground-truth","label","as","one","modality",".","This","class","is","independent","of","specific","data","modalities","and","models","."]
docstr: Parameters
  ----------
  data
      A pd.DataFrame containing multimodal features.
  preprocessor
      A list of multimodal feature preprocessors generating model-agnostic features.
  processors
      Data processors customizing data for each modality per model.
  id_mappings
      Id-to-content mappings. The contents can be text, image, etc.
      This is used when the dataframe contains the query/response indexes instead of their contents.
  is_training
      Whether in training mode. Some data processing may be different between training
      and validation/testing/prediction, e.g., image data augmentation is used only in
      training.
  model_config
      Model config used to decided dataset type. e.g. if multi_image_mix_dataset is used in detection model,
      MultiImageMixDataset will be used instead of BaseDataset
docstr_tok: ["Parameters","--","--","--","--","--","data","A","pd.DataFrame","containing","multimodal","features",".","preprocessor","A","list","of","multimodal","feature","preprocessors","generating","model-agnostic","features",".","processors","Data","processors","customizing","data","for","each","modality","per","model",".","id_mappings","Id-to-content","mappings",".","The","contents","can","be","text",",","image",",","etc",".","This","is","used","when","the","dataframe","contains","the","query\/response","indexes","instead","of","their","contents",".","is_training","Whether","in","training","mode",".","Some","data","processing","may","be","different","between","training","and","validation\/testing\/prediction",",","e.g.",",","image","data","augmentation","is","used","only","in","training",".","model_config","Model","config","used","to","decided","dataset","type",".","e.g",".","if","multi_image_mix_dataset","is","used","in","detection","model",",","MultiImageMixDataset","will","be","used","instead","of","BaseDataset"]
code: def __init__(
      self,
      data: pd.DataFrame,
      preprocessor: List[MultiModalFeaturePreprocessor],
      processors: List[dict],
      model_config: MMConfig,
      id_mappings: Optional[
          Union[Dict[str, Dict], Dict[str, pd.Series]]
      ] = None,
      is_training: bool = False,
  ):
      """
      Parameters
      ----------
      data
          A pd.DataFrame containing multimodal features.
      preprocessor
          A list of multimodal feature preprocessors generating model-agnostic features.
      processors
          Data processors customizing data for each modality per model.
      id_mappings
          Id-to-content mappings. The contents can be text, image, etc.
          This is used when the dataframe contains the query/response indexes instead of their contents.
      is_training
          Whether in training mode. Some data processing may be different between training
          and validation/testing/prediction, e.g., image data augmentation is used only in
          training.
      model_config
          Model config used to decided dataset type. e.g. if multi_image_mix_dataset is used in detection model,
          MultiImageMixDataset will be used instead of BaseDataset
      """
      super().__init__()
      self.processors = processors
      self.is_training = is_training
      self._consecutive_errors = 0
  
      mix_config = model_config[MULTI_IMAGE_MIX_DATASET]
      self.mix_data_key = "mmdet_image_image"  # the key of the data to mix, TODO: remove hardcoding
      self.mix_result_key = (
          "mix_results"  # the key of the mix result to store
      )
  
      self.mix_transforms = []
      self.mix_transforms_types = []  # TODO: remove hardcode
      if "mosaic" in mix_config:
          self.mix_transforms.append(Mosaic(**mix_config["mosaic"]))
          self.mix_transforms_types.append("mosaic")
      if "mixup" in mix_config:
          self.mix_transforms.append(MixUp(**mix_config["mixup"]))
          self.mix_transforms_types.append("mixup")
  
      self._skip_type_keys = None  # TODO: remove hardcode, we need to disable multi image mix in late epochs
      self.max_refetch = (
          15  # TODO: remove hardcode (do we need refetch?)
      )
  
      self.lengths = []
  
      for i, (per_preprocessor, per_processors_group) in enumerate(
          zip(preprocessor, processors)
      ):
          (
              modality_features,
              modality_types,
              length,
          ) = apply_df_preprocessor(
              data=data,
              df_preprocessor=per_preprocessor,
              modalities=per_processors_group.keys(),
          )
          self.lengths.append(length)
          setattr(self, f"modality_features_{i}", modality_features)
          setattr(self, f"modality_types_{i}", modality_types)
  
      assert len(set(self.lengths)) == 1
  
      self.id_mappings = id_mappings
  
imports: import collections
  import copy
  import logging
  import math
  from typing import Dict, List, Optional, Sequence, Tuple, Union
  import mmcv
  import numpy
  import pandas
  import torch
  from mmcv.transforms import BaseTransform
  from mmcv.transforms.utils import cache_randomness
  from mmdet.structures.bbox import autocast_box_type
  from mmdet.utils import log_img_scale
  from mmengine.config import Config
  from mmengine.dataset import BaseDataset
  from numpy import random
  from ...constants import GET_ITEM_ERROR_RETRY, MULTI_IMAGE_MIX_DATASET, ROIS
  from ..preprocess_dataframe import MultiModalFeaturePreprocessor
  from ..utils import apply_data_processor, apply_df_preprocessor, get_per_sample_features
label_desc: Use image node_id 1 to create a new MultiImageMixDataset object from inherited base classes: torch.utils.data with example: obj = MultiImageMixDataset(data, preprocessor, processors, model_config, id_mappings, is_training)