class_docstr: General class for embeddings for any modality.
  
  # Parameters
  
  embeddings : `torch.nn.ModuleDict`
      Named embedding layers. Eg. `"word_embeddings"`, `"position_embeddings"`, etc.
      All the embedding layers are expected to have different inputs; the output
      of one will not be passed to the other. All the layers should have the same
      `embedding_dim`/`out_features`.
  embedding_size : `int`
      The `embedding_dim` of all the embedding layers.
  dropout : `float`
      The probability of an element to be zeroed.
class_docstr_tok: ["General","class","for","embeddings","for","any","modality",".","#","Parameters","embeddings",":","`","torch.nn.ModuleDict","`","Named","embedding","layers",".","Eg",".","`","``","word_embeddings","''","`",",","`","``","position_embeddings","''","`",",","etc",".","All","the","embedding","layers","are","expected","to","have","different","inputs",";","the","output","of","one","will","not","be","passed","to","the","other",".","All","the","layers","should","have","the","same","`","embedding_dim","`","\/","`","out_features","`",".","embedding_size",":","`","int","`","The","`","embedding_dim","`","of","all","the","embedding","layers",".","dropout",":","`","float","`","The","probability","of","an","element","to","be","zeroed","."]
code: def __init__(
      self,
      embeddings: torch.nn.ModuleDict,
      embedding_size: int,
      dropout: float,
      layer_norm_eps: float = 1e-12,  # different from Huggingface!
  ):
      super().__init__()
      for name, embedding_layer in embeddings.named_children():
          if isinstance(embedding_layer, torch.nn.Embedding):
              assert embedding_layer.embedding_dim == embedding_size
          elif isinstance(embedding_layer, torch.nn.Linear):
              assert embedding_layer.out_features == embedding_size
          else:
              raise TypeError(
                  'Layer "{}" must be of type `torch.nn.Embedding` or `torch.nn.Linear`.'.format(
                      name
                  )
              )
      self.embeddings = embeddings
      self.layer_norm = LayerNorm(embedding_size, eps=layer_norm_eps)
      self.dropout = torch.nn.Dropout(dropout)
  
file_path: allennlp/allennlp/modules/transformer/transformer_embeddings.py
imports: from typing import Optional, TYPE_CHECKING
  import torch
  from allennlp.common import FromParams
  from allennlp.modules.transformer.layer_norm import LayerNorm
  from allennlp.modules.transformer.transformer_module import TransformerModule
label_desc: Use image node_id 1 to create a new Embeddings object from inherited base classes: TransformerModule, FromParams with example: obj = Embeddings(embeddings, embedding_size, dropout, layer_norm_eps)