code: def from_text_file(
      embeddings_file_path: str,
      update_embeddings: bool = False,
      item_separator: str = " ",
      tokenizer=WhitespaceTokenizer(),
      max_vocab_size: int = None,
  ):
      logger.info(
          "Read in embeddings file {}".format(embeddings_file_path)
      )
  
      if not os.path.exists(embeddings_file_path):
          logger.info(
              "{} does not exist, try to download from server".format(
                  embeddings_file_path
              )
          )
  
          if (
              "/" in embeddings_file_path
              or "\\" in embeddings_file_path
          ):
              raise ValueError(
                  "Embeddings file not found: {}".format(
                      embeddings_file_path
                  )
              )
  
          url = (
              "https://public.ukp.informatik.tu-darmstadt.de/reimers/embeddings/"
              + embeddings_file_path
          )
          http_get(url, embeddings_file_path)
  
      embeddings_dimension = None
      vocab = []
      embeddings = []
  
      with gzip.open(
          embeddings_file_path, "rt", encoding="utf8"
      ) if embeddings_file_path.endswith(".gz") else open(
          embeddings_file_path, encoding="utf8"
      ) as fIn:
          iterator = tqdm(
              fIn, desc="Load Word Embeddings", unit="Embeddings"
          )
          for line in iterator:
              split = line.rstrip().split(item_separator)
  
              if (
                  not vocab and len(split) == 2
              ):  # Handle Word2vec format
                  continue
  
              word = split[0]
  
              if embeddings_dimension is None:
                  embeddings_dimension = len(split) - 1
                  vocab.append("PADDING_TOKEN")
                  embeddings.append(np.zeros(embeddings_dimension))
  
              if (
                  len(split) - 1
              ) != embeddings_dimension:  # Assure that all lines in the embeddings file are of the same length
                  logger.error(
                      "ERROR: A line in the embeddings file had more or less  dimensions than expected. Skip token."
                  )
                  continue
  
              vector = np.array([float(num) for num in split[1:]])
              embeddings.append(vector)
              vocab.append(word)
  
              if (
                  max_vocab_size is not None
                  and max_vocab_size > 0
                  and len(vocab) > max_vocab_size
              ):
                  break
  
          embeddings = np.asarray(embeddings)
  
          tokenizer.set_vocab(vocab)
          return WordEmbeddings(
              tokenizer=tokenizer,
              embedding_weights=embeddings,
              update_embeddings=update_embeddings,
          )
  
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 8 for calling the WordEmbeddings obj's underlying member method code with example usage: obj.from_text_file(embeddings_file_path, update_embeddings, item_separator, tokenizer, max_vocab_size) and returns: WordEmbeddings