docstr: process data to get a batch.
  
  Parameters
  ----------
  data
      A dataframe.
  df_preprocessor
      Dataframe preprocessors.
  data_processors
      Data processors.
  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.
  
  Returns
  -------
  A dict of tensors.
docstr_tok: ["process","data","to","get","a","batch",".","Parameters","--","--","--","--","--","data","A","dataframe",".","df_preprocessor","Dataframe","preprocessors",".","data_processors","Data","processors",".","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",".","Returns","--","--","--","-","A","dict","of","tensors","."]
code: def process_batch(
      self,
      data: pd.DataFrame,
      df_preprocessor: Union[
          MultiModalFeaturePreprocessor,
          List[MultiModalFeaturePreprocessor],
      ],
      data_processors: Union[Dict, List[Dict]],
      id_mappings: Union[Dict[str, Dict], Dict[str, pd.Series]] = None,
  ):
      """
      process data to get a batch.
  
      Parameters
      ----------
      data
          A dataframe.
      df_preprocessor
          Dataframe preprocessors.
      data_processors
          Data processors.
      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.
  
      Returns
      -------
      A dict of tensors.
      """
      if isinstance(df_preprocessor, MultiModalFeaturePreprocessor):
          df_preprocessor = [df_preprocessor]
      if isinstance(data_processors, dict):
          data_processors = [data_processors]
  
      modality_features = dict()
      modality_types = dict()
      sample_num = dict()
  
      for i, (per_preprocessor, per_processors_group) in enumerate(
          zip(df_preprocessor, data_processors)
      ):
          (
              modality_features[i],
              modality_types[i],
              sample_num[i],
          ) = apply_df_preprocessor(
              data=data,
              df_preprocessor=per_preprocessor,
              modalities=per_processors_group.keys(),
          )
      sample_num = list(sample_num.values())
      assert len(set(sample_num)) == 1
      sample_num = sample_num[0]
  
      processed_features = []
      for i in range(sample_num):
          per_sample_features = dict()
          for group_id, per_processors_group in enumerate(
              data_processors
          ):
              per_sample_features_group = get_per_sample_features(
                  modality_features=modality_features[group_id],
                  modality_types=modality_types[group_id],
                  idx=i,
                  id_mappings=id_mappings,
              )
              per_sample_features_group = apply_data_processor(
                  per_sample_features=per_sample_features_group,
                  data_processors=per_processors_group,
                  feature_modalities=modality_types[group_id],
                  is_training=False,
              )
              per_sample_features.update(per_sample_features_group)
  
          processed_features.append(per_sample_features)
  
      collate_fn = get_collate_fn(
          df_preprocessor=df_preprocessor,
          data_processors=data_processors,
          per_gpu_batch_size=sample_num,
      )
      batch = collate_fn(processed_features)
  
      return batch
  
file_path: autogluon/multimodal/src/autogluon/multimodal/utils/inference.py
imports: import logging
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import pandas
  import torch
  from omegaconf import OmegaConf
  from scipy.special import softmax
  from torch import nn
  from ..constants import BBOX, COLUMN_FEATURES, FEATURES, IMAGE, IMAGE_META, LOGITS, MASKS, NER_ANNOTATION, NER_RET, OVD_RET, PROBABILITY, PROMPT, QUERY, RESPONSE, SCORE, SEMANTIC_MASK, TEXT, TOKEN_WORD_MAPPING, WORD_OFFSETS
  from ..data.preprocess_dataframe import MultiModalFeaturePreprocessor
  from ..data.utils import apply_data_processor, apply_df_preprocessor, get_collate_fn, get_per_sample_features
  from ..models.utils import run_model
  from .environment import get_precision_context, move_to_device
  from .matcher import compute_matching_probability
  from .misc import tensor_to_ndarray
label_desc: Use image node_id 4 for calling the RealtimeMixin obj's underlying member method code with example usage: obj.process_batch(data, df_preprocessor, data_processors, id_mappings) and returns: batch