class_docstr: UNITER wrapper for classification
  
  Example params:
      head_configs = {"vqa2": {"type": "mlp", "num_labels": 3129}}
      losses_configs = {"vqa2": "logit_bce"}
      tasks = "vqa2"
class_docstr_tok: ["UNITER","wrapper","for","classification","Example","params",":","head_configs","=","{","``","vqa2","''",":","{","``","type","''",":","``","mlp","''",",","``","num_labels","''",":","3129","}","}","losses_configs","=","{","``","vqa2","''",":","``","logit_bce","''","}","tasks","=","``","vqa2","''"]
code: def __init__(
      self,
      head_configs: Dict,
      loss_configs: Dict,
      tasks: Union[str, List],
      random_init: bool = False,
      bert_model_name: str = "bert-base-uncased",
      img_dim: int = 2048,
      hidden_size: int = 768,
      hidden_dropout_prob: float = 0,
      text_embeddings: Any = EMPTY_CONFIG,
      encoder: Any = EMPTY_CONFIG,
  ):
      super().__init__()
      self.loss_configs = loss_configs
      self.uniter = UNITERModelBase(
          random_init=random_init,
          bert_model_name=bert_model_name,
          img_dim=img_dim,
          hidden_size=hidden_size,
          hidden_dropout_prob=hidden_dropout_prob,
          text_embeddings=text_embeddings,
          encoder=encoder,
      )
  
      self.heads = nn.ModuleDict()
      self.tasks = tasks
      if isinstance(self.tasks, str):
          self.tasks = self.tasks.split(",")
  
      for task in self.tasks:
          assert task in head_configs, (
              f"Task {task} is specified in your model configs"
              + " but there is no head configured for the task. "
              + "Head configs can be added under model_config.heads "
              + "in your yaml configs. Either remove this task if UNITER"
              + " is not meant to run on a dataset named {task}"
              + " or add a head config."
          )
          head_config = head_configs[task]
          head_type = head_config.get("type", "mlp")
          head_class = registry.get_transformer_head_class(head_type)
          self.heads[task] = head_class(head_config)
  
      self.init_losses()
  
imports: import copy
  import logging
  import random
  from collections import namedtuple
  from collections.abc import MutableMapping
  from dataclasses import asdict, dataclass, field
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from mmf.common.registry import registry
  from mmf.models import BaseModel
  from mmf.modules.losses import MMFLoss
  from mmf.utils.general import retry_n
  from omegaconf import DictConfig, MISSING, OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 1 to create a new UNITERForClassification object from inherited base classes: nn with example: obj = UNITERForClassification(head_configs, loss_configs, tasks, random_init, bert_model_name, img_dim, hidden_size, hidden_dropout_prob, text_embeddings, encoder)