class_docstr: Word embedding class.
  
  Parameters
  ----------
  vocab_size : int
      The word vocabulary size.
  emb_size : int
      The word embedding size.
  padding_idx : int, optional
      The padding index, default: ``0``.
  pretrained_word_emb : numpy.ndarray, optional
      The pretrained word embeddings, default: ``None``.
  fix_emb : boolean, optional
      Specify whether to fix pretrained word embeddings, default: ``True``.
  
  Examples
  ----------
  >>> emb_layer = WordEmbedding(500, 300, padding_idx=0, pretrained_word_emb=None, fix_emb=True)
class_docstr_tok: ["Word","embedding","class",".","Parameters","--","--","--","--","--","vocab_size",":","int","The","word","vocabulary","size",".","emb_size",":","int","The","word","embedding","size",".","padding_idx",":","int",",","optional","The","padding","index",",","default",":","``","0","``",".","pretrained_word_emb",":","numpy.ndarray",",","optional","The","pretrained","word","embeddings",",","default",":","``","None","``",".","fix_emb",":","boolean",",","optional","Specify","whether","to","fix","pretrained","word","embeddings",",","default",":","``","True","``",".","Examples","--","--","--","--","--",">",">",">","emb_layer","=","WordEmbedding","(","500",",","300",",","padding_idx=0",",","pretrained_word_emb=None",",","fix_emb=True",")"]
code: def __init__(
      self,
      vocab_size,
      emb_size,
      padding_idx=0,
      pretrained_word_emb=None,
      fix_emb=True,
  ):
      super(WordEmbedding, self).__init__()
      self.word_emb_layer = nn.Embedding(
          vocab_size,
          emb_size,
          padding_idx=padding_idx,
          _weight=torch.from_numpy(pretrained_word_emb).float()
          if pretrained_word_emb is not None
          else None,
      )
  
      if fix_emb:
          print("[ Fix word embeddings ]")
          for param in self.word_emb_layer.parameters():
              param.requires_grad = False
  
imports: import torch
  from torch import nn
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
  from ...data.data import from_batch
  from ..utils.bert_utils import convert_text_to_bert_features, extract_bert_hidden_states
  from ..utils.generic_utils import dropout_fn
  from ..utils.padding_utils import pad_4d_vals
  from ..utils.vocab_utils import Vocab
label_desc: Use image node_id 1 to create a new WordEmbedding object from inherited base classes: nn with example: obj = WordEmbedding(vocab_size, emb_size, padding_idx, pretrained_word_emb, fix_emb)