class_docstr: Construct the embeddings from word, position and token_type embeddings.
  Details in the paper:
  [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding, Devlin et al, 2019]
  (https://api.semanticscholar.org/CorpusID:52967399)
  
  # Parameters
  
  vocab_size : `int`
      The size of the input vocab.
  embedding_size : `int`
      The `embedding_dim` of all the embedding layers.
  pad_token_id : `int` (default = `0`)
      The token id of the `<pad>` token.
  max_position_embeddings : `int` (default = `512`)
      The maximum number of positions.
  type_vocab_size : `int` (default = `2`)
      The size of the input token_type vocab.
  dropout : `int` (default = `0.1`)
      The probability of an element to be zeroed.
  output_size : `int`, optional (default = `None`)
      Optionally apply a linear transform after the dropout, projecting to `output_size`.
class_docstr_tok: ["Construct","the","embeddings","from","word",",","position","and","token_type","embeddings",".","Details","in","the","paper",":","[","BERT",":","Pre-training","of","Deep","Bidirectional","Transformers","for","Language","Understanding",",","Devlin","et","al",",","2019","]","(","https",":","\/\/api.semanticscholar.org\/CorpusID:52967399",")","#","Parameters","vocab_size",":","`","int","`","The","size","of","the","input","vocab",".","embedding_size",":","`","int","`","The","`","embedding_dim","`","of","all","the","embedding","layers",".","pad_token_id",":","`","int","`","(","default","=","`","0","`",")","The","token","id","of","the","`","<","pad",">","`","token",".","max_position_embeddings",":","`","int","`","(","default","=","`","512","`",")","The","maximum","number","of","positions",".","type_vocab_size",":","`","int","`","(","default","=","`","2","`",")","The","size","of","the","input","token_type","vocab",".","dropout",":","`","int","`","(","default","=","`","0.1","`",")","The","probability","of","an","element","to","be","zeroed",".","output_size",":","`","int","`",",","optional","(","default","=","`","None","`",")","Optionally","apply","a","linear","transform","after","the","dropout",",","projecting","to","`","output_size","`","."]
code: def __init__(
      self,
      vocab_size: int,
      embedding_size: int,
      pad_token_id: int = 0,
      max_position_embeddings: int = 512,
      position_pad_token_id: Optional[int] = None,
      type_vocab_size: int = 2,
      dropout: float = 0.1,
      layer_norm_eps: float = 1e-12,  # different from Huggingface!
      output_size: Optional[int] = None,
  ):
      embedding_dict = {}
  
      word_embeddings = torch.nn.Embedding(
          vocab_size, embedding_size, padding_idx=pad_token_id
      )
      embedding_dict["word_embeddings"] = word_embeddings
  
      if max_position_embeddings > 0:
          position_embeddings = torch.nn.Embedding(
              max_position_embeddings,
              embedding_size,
              padding_idx=position_pad_token_id,
          )
          embedding_dict["position_embeddings"] = position_embeddings
  
      if type_vocab_size > 0:
          token_type_embeddings = torch.nn.Embedding(
              type_vocab_size, embedding_size
          )
          embedding_dict[
              "token_type_embeddings"
          ] = token_type_embeddings
  
      embeddings = torch.nn.ModuleDict(embedding_dict)
  
      super().__init__(
          embeddings,
          embedding_size,
          dropout,
          layer_norm_eps=layer_norm_eps,
      )
  
      # For Albert, the embedding size is different than the hidden size used
      # in the model, so a linear transform is applied.
      if output_size:
          self.linear_transform = torch.nn.Linear(
              embedding_size, output_size
          )
  
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 TransformerEmbeddings object from inherited base classes: Embeddings with example: obj = TransformerEmbeddings(vocab_size, embedding_size, pad_token_id, max_position_embeddings, position_pad_token_id, type_vocab_size, dropout, layer_norm_eps, output_size)