class_docstr: A word embedding wrapper module around `torch.nn.Embedding` with options to
  initialize the word embedding weights and add MLP layers acting on each word.
  
  Note: Embedding weights for UNK token are always initialized to zeros.
  
  Args:
      num_embeddings (int): Total number of words/tokens (vocabulary size).
      embedding_dim (int): Size of embedding vector.
      embeddings_weight (torch.Tensor): Pretrained weights to initialize the
          embedding table with.
      init_range (List[int]): Range of uniform distribution to initialize the
          weights with if `embeddings_weight` is None.
      unk_token_idx (int): Index of UNK token in the word vocabulary.
      mlp_layer_dims (List[int]): List of layer dimensions (if any) to add
          on top of the embedding lookup.
class_docstr_tok: ["A","word","embedding","wrapper","module","around","`","torch.nn.Embedding","`","with","options","to","initialize","the","word","embedding","weights","and","add","MLP","layers","acting","on","each","word",".","Note",":","Embedding","weights","for","UNK","token","are","always","initialized","to","zeros",".","Args",":","num_embeddings","(","int",")",":","Total","number","of","words\/tokens","(","vocabulary","size",")",".","embedding_dim","(","int",")",":","Size","of","embedding","vector",".","embeddings_weight","(","torch.Tensor",")",":","Pretrained","weights","to","initialize","the","embedding","table","with",".","init_range","(","List","[","int","]",")",":","Range","of","uniform","distribution","to","initialize","the","weights","with","if","`","embeddings_weight","`","is","None",".","unk_token_idx","(","int",")",":","Index","of","UNK","token","in","the","word","vocabulary",".","mlp_layer_dims","(","List","[","int","]",")",":","List","of","layer","dimensions","(","if","any",")","to","add","on","top","of","the","embedding","lookup","."]
code: def __init__(
      self,
      num_embeddings: int,
      embedding_dim: int = 300,
      embeddings_weight: Optional[torch.Tensor] = None,
      init_range: Optional[List[int]] = None,
      init_std: Optional[float] = None,
      unk_token_idx: int = 0,
      mlp_layer_dims: List[int] = (),
      padding_idx: Optional[int] = None,
      vocab: Optional[List[str]] = None,
  ) -> None:
      output_embedding_dim = (
          mlp_layer_dims[-1] if mlp_layer_dims else embedding_dim
      )
      EmbeddingBase.__init__(self, embedding_dim=output_embedding_dim)
  
      # Create word embedding
      self.word_embedding = nn.Embedding(
          num_embeddings,
          embedding_dim,
          _weight=embeddings_weight,
          padding_idx=padding_idx,
      )
      if embeddings_weight is None:
          if init_range:
              self.word_embedding.weight.data.uniform_(
                  init_range[0], init_range[1]
              )
          if init_std:
              self.word_embedding.weight.data.normal_(
                  mean=0.0, std=init_std
              )
  
      # Initialize unk embedding with zeros
      # to guard the model against randomized decisions based on unknown words
      self.word_embedding.weight.data[unk_token_idx].fill_(0.0)
  
      # Create MLP layers
      if mlp_layer_dims is None:
          mlp_layer_dims = []
      self.mlp = nn.Sequential(
          *(
              nn.Sequential(nn.Linear(m, n), nn.ReLU())
              for m, n in zip(
                  [embedding_dim] + list(mlp_layer_dims), mlp_layer_dims
              )
          )
      )
      self.vocab = vocab
      self.padding_idx = padding_idx
      log_class_usage(__class__)
  
file_path: pytext/pytext/models/embeddings/word_embedding.py
imports: import collections
  from typing import List, Optional
  import torch
  from pytext.config.field_config import WordFeatConfig
  from pytext.data.tensorizers import Tensorizer
  from pytext.fields import FieldMeta
  from pytext.models.embeddings.embedding_base import EmbeddingBase
  from pytext.utils.usage import log_class_usage
  from pytorch.text.fb.utils.embeddings import PretrainedEmbedding
  from torch import nn
  from torch.utils.tensorboard import SummaryWriter
label_desc: Use image node_id 2 to create a new WordEmbedding object from inherited base classes: EmbeddingBase with example: obj = WordEmbedding(num_embeddings, embedding_dim, embeddings_weight, init_range, init_std, unk_token_idx, mlp_layer_dims, padding_idx, vocab)