class_docstr: Embedding from token and position embeddings.
  Optionally add token_type embedding (e.g. type of the sentence in BERT).
  
  Args:
      vocab_size: size of the vocabulary
      hidden_size: size of the embeddings in the model, also known as d_model
      max_sequence_length: maximum allowed length of the input sequence
      num_token_types: number of different token types
          (e.g. tokens of sentence A and tokens of sentence B in BERT)
      embedding_dropout: probability of dropout applied to embeddings
      learn_positional_encodings: whether to learn positional encodings or
          use fixed (sine-cosine) ones
class_docstr_tok: ["Embedding","from","token","and","position","embeddings",".","Optionally","add","token_type","embedding","(","e.g",".","type","of","the","sentence","in","BERT",")",".","Args",":","vocab_size",":","size","of","the","vocabulary","hidden_size",":","size","of","the","embeddings","in","the","model",",","also","known","as","d_model","max_sequence_length",":","maximum","allowed","length","of","the","input","sequence","num_token_types",":","number","of","different","token","types","(","e.g",".","tokens","of","sentence","A","and","tokens","of","sentence","B","in","BERT",")","embedding_dropout",":","probability","of","dropout","applied","to","embeddings","learn_positional_encodings",":","whether","to","learn","positional","encodings","or","use","fixed","(","sine-cosine",")","ones"]
code: def __init__(
      self,
      vocab_size: int,
      hidden_size: int,
      max_sequence_length: int = 512,
      num_token_types: int = 2,
      embedding_dropout: float = 0.0,
      learn_positional_encodings: bool = False,
      padding_idx: int = 0,
  ):
      super().__init__()
  
      self.max_sequence_length = max_sequence_length
      self.learn_positional_encodings = learn_positional_encodings
      self.token_embedding = nn.Embedding(
          vocab_size, hidden_size, padding_idx=padding_idx
      )
      if learn_positional_encodings:
          self.position_embedding = nn.Embedding(
              max_sequence_length, hidden_size
          )
      else:
          self.position_embedding = FixedPositionalEncoding(
              hidden_size, max_sequence_length
          )
      if num_token_types > 0:
          self.token_type_embedding = nn.Embedding(
              num_token_types, hidden_size
          )
      self.layer_norm = nn.LayerNorm(hidden_size, eps=1e-5)
      self.dropout = nn.Dropout(embedding_dropout)
  
imports: import math
  import numpy
  import torch
  from torch import nn
  from torch.nn.functional import gelu
  from nemo.collections.common.parts import form_attention_mask
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new TransformerEmbedding object from inherited base classes: nn with example: obj = TransformerEmbedding(vocab_size, hidden_size, max_sequence_length, num_token_types, embedding_dropout, learn_positional_encodings, padding_idx)