class_docstr: A wrapper around the embedding layer, which can be randomly initialized or
  loaded from a .npy file. Also supports normalization of embeddings to have
  zero mean and unit variance (weighted by token frequency) - this is useful
  for example when creating adversarial perturbations of the embeddings that
  should have norms relative to the embeddings' norms.
class_docstr_tok: ["A","wrapper","around","the","embedding","layer",",","which","can","be","randomly","initialized","or","loaded","from","a",".npy","file",".","Also","supports","normalization","of","embeddings","to","have","zero","mean","and","unit","variance","(","weighted","by","token","frequency",")","-","this","is","useful","for","example","when","creating","adversarial","perturbations","of","the","embeddings","that","should","have","norms","relative","to","the","embeddings","'","norms","."]
code: def __init__(
      self,
      num_embeddings,
      embedding_dim,
      padding_idx,
      freeze_embed=False,
      normalize_embed=False,
      normalize_decay_rate=0.99,
  ):
      super().__init__(
          num_embeddings, embedding_dim, padding_idx=padding_idx
      )
      nn.init.uniform_(self.weight, -0.1, 0.1)
      nn.init.constant_(self.weight[padding_idx], 0.0)
      if freeze_embed:
          self.weight.requires_grad = False
  
      assert 0.0 < normalize_decay_rate < 1.0
      self.normalize = normalize_embed
      self.normalize_decay_rate = normalize_decay_rate
      self.mean = None
      self.var = None
      self.init_normalization_if_needed()
  
imports: import abc
  import math
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.models import FairseqIncrementalDecoder, transformer
  from pytorch_translate import rnn_cell, utils, vocab_reduction
  from pytorch_translate.research.lexical_choice import lexical_translation
label_desc: Use image node_id 1 to create a new Embedding object from inherited base classes: nn with example: obj = Embedding(num_embeddings, embedding_dim, padding_idx, freeze_embed, normalize_embed, normalize_decay_rate)