class_docstr: Document Classification with Huggingface backbones. Inherit from HFAutoModelForTextPrediction.
docstr: Parameters
  ----------
  batch
      A dictionary containing the input mini-batch data.
      We need to use the keys with the model prefix to index required data.
  
  Returns
  -------
      A dictionary with logits and features.
docstr_tok: ["Parameters","--","--","--","--","--","batch","A","dictionary","containing","the","input","mini-batch","data",".","We","need","to","use","the","keys","with","the","model","prefix","to","index","required","data",".","Returns","--","--","--","-","A","dictionary","with","logits","and","features","."]
code: def forward(
      self,
      batch: dict,
  ):
      """
      Parameters
      ----------
      batch
          A dictionary containing the input mini-batch data.
          We need to use the keys with the model prefix to index required data.
  
      Returns
      -------
          A dictionary with logits and features.
      """
      input_data = {}
      self.update_input_data(
          input_data,
          batch,
          keys={
              INPUT_IDS: self.text_token_ids_key,
              TOKEN_TYPE_IDS: self.text_segment_ids_key,
              ATTENTION_MASK: self.text_attention_mask_key,
              BBOX: self.text_bbox_key,
              PIXEL_VALUES: self.document_pixel_value_key,
              IMAGE: self.document_pixel_value_key,
          },
      )
  
      text_masks = batch[self.text_attention_mask_key]
  
      outputs = self.model(**input_data)
  
      if self.pooling_mode == "cls":
          pooled_features = outputs.last_hidden_state[:, 0, :]
      elif self.pooling_mode == "mean":
          # In some models, last_hidden_state is the concatenation of document image features and text features.
          pooled_features = outputs.last_hidden_state.mean(1)
      else:
          raise NotImplementedError(
              f"Pooling mode={self.pooling_mode} is not supported."
          )
  
      logits = self.head(pooled_features)
  
      ret = {COLUMN_FEATURES: {FEATURES: {}, MASKS: {}}}
      column_features, column_feature_masks = get_column_features(
          batch=batch,
          column_name_prefix=self.text_column_prefix,
          features=outputs.last_hidden_state,
          valid_lengths=sum(text_masks),
          cls_feature=pooled_features,
      )
      ret[COLUMN_FEATURES][FEATURES].update(column_features)
      ret[COLUMN_FEATURES][MASKS].update(column_feature_masks)
  
      ret.update(
          {
              LOGITS: logits,
              FEATURES: pooled_features,
          }
      )
  
      return {self.prefix: ret}
  
file_path: autogluon/multimodal/src/autogluon/multimodal/models/document_transformer.py
imports: import inspect
  import logging
  from typing import Callable, Dict, List, Optional, Tuple, Union, cast
  from transformers import logging
  from ..constants import ATTENTION_MASK, AUTOMM, BBOX, COLUMN, COLUMN_FEATURES, FEATURES, IMAGE, INPUT_IDS, LABEL, LOGITS, MASKS, PIXEL_VALUES, TEXT_SEGMENT_IDS, TEXT_TOKEN_IDS, TEXT_VALID_LENGTH, TOKEN_TYPE_IDS
  from .huggingface_text import HFAutoModelForTextPrediction
  from .utils import get_column_features
label_desc: Use image node_id 7 for calling the DocumentTransformer obj's underlying member method code with example usage: obj.forward(batch) and returns: dict