code: def convert_WordEmbeddings(
      embedding_filename,
      vocab_filename,
      output_path,
      language="English",
  ):
      """
      Converts a Wordembedding model in word2vec format to a format that can be used inside FARM
      For compatibility special tokens are added to create embeddings for [CLS], [SEP], [UNK], [PAD] and [MASK]
      The embeddings for these special tokens are the average word embeddings of all other words
      #TODO save model in a more efficient format
  
      :param vector_filename: word2vec format embeddings. A txt file consisting of space separated word and n (dimension of
      embedding) embedding values for that word
      :type vector_filename: str
      :param vocab_filename: a txt file with each line containing a word and its associated count
      :type vocab_filename: str
      :param output_path: path to store the converted model
      :type output_path: str
      :return:
      """
      # creating vocab
      temp_vocab = load_word2vec_vocab(vocab_filename=vocab_filename)
      vocab = SPECIAL_TOKENS + temp_vocab
  
      # create embeddings
      temp_embeddings = load_embedding_vectors(
          embedding_file=embedding_filename, vocab=temp_vocab
      )
      mean_embedding = np.mean(temp_embeddings, axis=0)
      embeddings = np.zeros(
          (
              temp_embeddings.shape[0] + len(SPECIAL_TOKENS),
              temp_embeddings.shape[1],
          )
      )
      for i, tok in enumerate(SPECIAL_TOKENS):
          embeddings[i, :] = mean_embedding
      embeddings[len(SPECIAL_TOKENS) :, :] = temp_embeddings
  
      # create config
      lm_config = {
          "embeddings_filename": "vectors.txt",
          "hidden_size": embeddings.shape[1],
          "language": language,
          "name": "WordEmbedding_LM",
          "vocab_filename": "vocab.txt",
          "vocab_size": embeddings.shape[0],
      }
  
      # saving
      if not os.path.exists(output_path):
          os.makedirs(output_path)
      with open(
          Path(output_path) / "language_model_config.json", "w"
      ) as file:
          file.write(json.dumps(lm_config, indent=2))
  
      _save_word2vec_format(
          fname=str(
              Path(output_path) / lm_config["embeddings_filename"]
          ),
          fvocab=str(Path(output_path) / lm_config["vocab_filename"]),
          vocab=vocab,
          vectors=embeddings,
      )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import io
  import json
  import logging
  import os
  import unicodedata
  from pathlib import Path
  import numpy
  import pandas
  from tqdm import tqdm
  from transformers import BertTokenizer
  from sklearn.decomposition import TruncatedSVD
  from sklearn.cluster import KMeans
  from collections import Counter
  from farm.file_utils import load_from_cache
label_desc: Use image node_id 5 for calling a global function with example usage: convert_WordEmbeddings(embedding_filename, vocab_filename, output_path, language) without return types