class_docstr: Generic Modal Embeddings which takes in an encoder,
  and a transformer embedding.
class_docstr_tok: ["Generic","Modal","Embeddings","which","takes","in","an","encoder",",","and","a","transformer","embedding","."]
code: def __init__(self, config, encoder, embeddings):
      super().__init__()
      self.config = config
      self.encoder = encoder
      self.proj_embeddings = nn.Linear(
          config.modal_hidden_size, config.hidden_size
      )
      self.position_embeddings = embeddings.position_embeddings
      self.token_type_embeddings = embeddings.token_type_embeddings
      self.word_embeddings = embeddings.word_embeddings
      self.LayerNorm = embeddings.LayerNorm
      self.dropout = nn.Dropout(p=config.hidden_dropout_prob)
  
imports: import os
  from copy import deepcopy
  from dataclasses import dataclass
  from typing import Dict, Optional, Union
  import torch
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.models.interfaces.mmbt import MMBTGridHMInterface
  from mmf.modules.encoders import EncoderFactory, ImageEncoderFactory, ImageEncoderTypes, MultiModalEncoderBase, ResNet152ImageEncoder, TextEncoderFactory, TextEncoderTypes, TransformerEncoder
  from mmf.modules.hf_layers import replace_with_jit
  from mmf.utils.checkpoint import load_pretrained_model
  from mmf.utils.configuration import get_mmf_cache_dir
  from mmf.utils.modeling import get_optimizer_parameters_for_bert
  from omegaconf import DictConfig, II, OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 1 to create a new ModalEmbeddings object from inherited base classes: nn with example: obj = ModalEmbeddings(config, encoder, embeddings)