class_docstr: Embedding class that can take any number of image or text modalities, each can
  have their input id, position id and segment id. We generate embeddings of
  dimension config.hidden_size for each and then first add the three embeddings
  for each modality to have a modality specific embedding. We then concat the
  modality specific embeddings to have a joint embedding.
class_docstr_tok: ["Embedding","class","that","can","take","any","number","of","image","or","text","modalities",",","each","can","have","their","input","id",",","position","id","and","segment","id",".","We","generate","embeddings","of","dimension","config.hidden_size","for","each","and","then","first","add","the","three","embeddings","for","each","modality","to","have","a","modality","specific","embedding",".","We","then","concat","the","modality","specific","embeddings","to","have","a","joint","embedding","."]
code: def __init__(
      self,
      model_config: BaseTransformer.Config,
      transformer_config: Dict[str, Any],
      transformer: Type[nn.Module],
      *args,
      **kwargs,
  ):
      super().__init__()
      self.model_config = model_config
      self.transformer_config = transformer_config
  
      self.token_embeddings = nn.ModuleList()
      self.pos_embeddings = nn.ModuleList()
      self.layer_norms = nn.ModuleList()
      self.dropouts = nn.ModuleList()
      self.modality_keys: List = []
  
      # Build layers for each modality and initialize
      self.build_layers()
      self.init_weights(transformer)
  
      assert (
          len(self.token_embeddings)
          == len(self.pos_embeddings)
          == len(self.layer_norms)
          == len(self.dropouts)
          == len(self.model_config.modalities)
      )
  
imports: from copy import deepcopy
  from typing import Any, Dict, List, Type
  import torch
  from mmf.common.registry import registry
  from mmf.models.transformers.base import BaseTransformer, BaseTransformerBackend
  from mmf.modules.hf_layers import BertModelJit, replace_with_jit
  from omegaconf import OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 1 to create a new HuggingfaceEmbeddings object from inherited base classes: nn with example: obj = HuggingfaceEmbeddings(model_config, transformer_config, transformer)