class_docstr: UNITER wrapper for pretraining
class_docstr_tok: ["UNITER","wrapper","for","pretraining"]
code: def __init__(
      self,
      head_configs: Optional[Dict] = None,
      loss_configs: Optional[Dict] = None,
      tasks: Union[List, str] = DEFAULT_PRETRAINING_TASKS,
      mask_probability: float = 0,
      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__()
      if head_configs is None:
          head_configs = copy.deepcopy(DEFAULT_PRETRAINING_HEAD_CONFIGS)
  
      if loss_configs is None:
          loss_configs = {}
  
      self.loss_configs = loss_configs
      self.mask_probability = mask_probability
      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:
          head_config = head_configs[task]
          head_type = head_config.get("type", "mlp")
          head_class = registry.get_transformer_head_class(head_type)
          if head_type == "mrfr":
              self.heads[task] = head_class(
                  self.uniter.img_embeddings.img_linear.weight,
                  **head_config,
              )
          elif head_type in ("itm", "mlm", "mlp"):
              self.heads[task] = head_class(head_config)
          else:
              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 UNITERForPretraining object from inherited base classes: nn with example: obj = UNITERForPretraining(head_configs, loss_configs, tasks, mask_probability, random_init, bert_model_name, img_dim, hidden_size, hidden_dropout_prob, text_embeddings, encoder)