code: def __init__(self, config: Config, *args, **kwargs):
      super().__init__(config, *args, **kwargs)
      self.cls = BertOnlyMLMHead(self.config)
      loss_dict = dict(
          mse=torch.nn.MSELoss(),
          cosine=torch.nn.CosineSimilarity(dim=1),
          contrastive=RefinerContrastiveLoss(),
          ms=RefinerMSLoss(),
      )
      self.refiner_loss = loss_dict.get(self.config.loss_type)
  
      self.refiner_decoder = {}
      self.weights = {}
      for i, modality in enumerate(self.config.modalities):
          self.refiner_decoder[modality] = MLP(
              input_dim=self.config.hidden_size,
              mlp_dims=[self.config.hidden_size],
              dropout=self.config.hidden_dropout_prob,
              nonlinearity=torch.nn.ReLU,
              normalization=torch.nn.LayerNorm,
          )
          self.weights[modality] = self.config.weights[i]
  
      self.modalities = self.config.modalities
      self.tol = self.config.tol
      self.refiner_target_pooler = self.config.refiner_target_pooler
      self.refiner_target_layer_depth = (
          self.config.refiner_target_layer_depth
      )
      self.loss_name = self.config.loss_name
  
      pool_class = registry.get_pool_class(self.refiner_target_pooler)
      if pool_class is None:
          raise ValueError(
              f"No pooler {self.refiner_target_pooler} is\
                               registered to registry"
          )
      self.pooler = pool_class(self.refiner_target_layer_depth)
  
file_path: mmf/mmf/models/transformers/heads/refiner.py
imports: from dataclasses import dataclass, field
  from typing import Dict, List, Optional, Type
  import torch
  from mmf.common.registry import registry
  from mmf.models.transformers.base import BaseTransformerHead
  from mmf.modules.losses import RefinerContrastiveLoss, RefinerMSLoss
  from torch import nn
label_desc: Use image node_id 1 to create a new Refiner object from inherited base classes: BaseTransformerHead with example: obj = Refiner(config)