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 build_layers(self):
      for modality in self.model_config.modalities:
          self.modality_keys.append(modality.key)
          layer_norm_eps = modality.get(
              "layer_norm_eps", self.transformer_config.layer_norm_eps
          )
          position_dim = modality.get(
              "position_dim",
              self.transformer_config.max_position_embeddings,
          )
          hidden_dropout_prob = modality.get(
              "hidden_dropout_prob",
              self.transformer_config.hidden_dropout_prob,
          )
          if modality.type == "text" and modality.get(
              "consume_raw", True
          ):
              self.token_embeddings.append(
                  nn.Embedding(
                      self.transformer_config.vocab_size,
                      self.transformer_config.hidden_size,
                      padding_idx=self.transformer_config.pad_token_id,
                  )
              )
          else:
              self.token_embeddings.append(
                  nn.Sequential(
                      nn.Linear(
                          modality.embedding_dim,
                          self.transformer_config.hidden_size,
                      ),
                      torch.nn.LayerNorm(
                          self.transformer_config.hidden_size,
                          eps=layer_norm_eps,
                      ),
                  )
              )
  
          self.pos_embeddings.append(
              nn.Embedding(
                  position_dim, self.transformer_config.hidden_size
              )
          )
          self.layer_norms.append(
              torch.nn.LayerNorm(
                  self.transformer_config.hidden_size,
                  eps=layer_norm_eps,
              )
          )
          self.dropouts.append(nn.Dropout(hidden_dropout_prob))
  
      self.token_type_embeddings = nn.Embedding(
          len(self.model_config.modalities),
          self.transformer_config.hidden_size,
      )
  
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 2 for calling the HuggingfaceEmbeddings obj's underlying member method code with example usage: obj.build_layers() without return types