code: def __init__(
      self,
      tokenizer: WordTokenizer,
      embedding_weights,
      update_embeddings: bool = False,
      max_seq_length: int = 1000000,
  ):
      nn.Module.__init__(self)
      if isinstance(embedding_weights, list):
          embedding_weights = np.asarray(embedding_weights)
  
      if isinstance(embedding_weights, np.ndarray):
          embedding_weights = torch.from_numpy(embedding_weights)
  
      num_embeddings, embeddings_dimension = embedding_weights.size()
      self.embeddings_dimension = embeddings_dimension
      self.emb_layer = nn.Embedding(
          num_embeddings, embeddings_dimension
      )
      self.emb_layer.load_state_dict({"weight": embedding_weights})
      self.emb_layer.weight.requires_grad = update_embeddings
      self.tokenizer = tokenizer
      self.update_embeddings = update_embeddings
      self.max_seq_length = max_seq_length
  
imports: import torch
  from torch import nn
  from typing import List
  import logging
  import gzip
  from tqdm import tqdm
  import numpy
  import os
  import json
  from ..util import import_from_string, fullname, http_get
  from .tokenizer import WordTokenizer, WhitespaceTokenizer
label_desc: Use image node_id 1 to create a new WordEmbeddings object from inherited base classes: nn with example: obj = WordEmbeddings(tokenizer, embedding_weights, update_embeddings, max_seq_length)