class_docstr: Class to simulate a WordEmbeddings class from flair.
  
  Run this to generate a headless (without word embeddings) model as well a stored word embeddings:
  
  >>> from flair.inference_utils import WordEmbeddingsStore
  >>> from flair.models import SequenceTagger
  >>> import pickle
  >>> tagger = SequenceTagger.load("multi-ner-fast")
  >>> WordEmbeddingsStore.create_stores(tagger)
  >>> pickle.dump(tagger, open("multi-ner-fast-headless.pickle", "wb"))
  
  The same but using LMDB as memory database:
  
  >>> from flair.inference_utils import WordEmbeddingsStore
  >>> from flair.models import SequenceTagger
  >>> import pickle
  >>> tagger = SequenceTagger.load("multi-ner-fast")
  >>> WordEmbeddingsStore.create_stores(tagger, backend='lmdb')
  >>> pickle.dump(tagger, open("multi-ner-fast-headless.pickle", "wb"))
  
  Then this can be used as follows:
  
  >>> from flair.data import Sentence
  >>> tagger = pickle.load(open("multi-ner-fast-headless.pickle", "rb"))
  >>> WordEmbeddingsStore.load_stores(tagger)
  >>> text = "Schade um den Ameisenbären. Lukas Bärfuss veröffentlicht Erzählungen aus zwanzig Jahren."
  >>> sentence = Sentence(text)
  >>> tagger.predict(sentence)
  >>> print(sentence.get_spans('ner'))
  
  The same but using LMDB as memory database:
  
  >>> from flair.data import Sentence
  >>> tagger = pickle.load(open("multi-ner-fast-headless.pickle", "rb"))
  >>> WordEmbeddingsStore.load_stores(tagger, backend='lmdb')
  >>> text = "Schade um den Ameisenbären. Lukas Bärfuss veröffentlicht Erzählungen aus zwanzig Jahren."
  >>> sentence = Sentence(text)
  >>> tagger.predict(sentence)
  >>> print(sentence.get_spans('ner'))
class_docstr_tok: ["Class","to","simulate","a","WordEmbeddings","class","from","flair",".","Run","this","to","generate","a","headless","(","without","word","embeddings",")","model","as","well","a","stored","word","embeddings",":",">",">",">","from","flair.inference_utils","import","WordEmbeddingsStore",">",">",">","from","flair.models","import","SequenceTagger",">",">",">","import","pickle",">",">",">","tagger","=","SequenceTagger.load","(","``","multi-ner-fast","''",")",">",">",">","WordEmbeddingsStore.create_stores","(","tagger",")",">",">",">","pickle.dump","(","tagger",",","open","(","``","multi-ner-fast-headless.pickle","''",",","``","wb","''",")",")","The","same","but","using","LMDB","as","memory","database",":",">",">",">","from","flair.inference_utils","import","WordEmbeddingsStore",">",">",">","from","flair.models","import","SequenceTagger",">",">",">","import","pickle",">",">",">","tagger","=","SequenceTagger.load","(","``","multi-ner-fast","''",")",">",">",">","WordEmbeddingsStore.create_stores","(","tagger",",","backend='lmdb","'",")",">",">",">","pickle.dump","(","tagger",",","open","(","``","multi-ner-fast-headless.pickle","''",",","``","wb","''",")",")","Then","this","can","be","used","as","follows",":",">",">",">","from","flair.data","import","Sentence",">",">",">","tagger","=","pickle.load","(","open","(","``","multi-ner-fast-headless.pickle","''",",","``","rb","''",")",")",">",">",">","WordEmbeddingsStore.load_stores","(","tagger",")",">",">",">","text","=","``","Schade","um","den","Ameisenb\u00e4ren",".","Lukas","B\u00e4rfuss","ver\u00f6ffentlicht","Erz\u00e4hlungen","aus","zwanzig","Jahren",".","''",">",">",">","sentence","=","Sentence","(","text",")",">",">",">","tagger.predict","(","sentence",")",">",">",">","print","(","sentence.get_spans","(","'ner","'",")",")","The","same","but","using","LMDB","as","memory","database",":",">",">",">","from","flair.data","import","Sentence",">",">",">","tagger","=","pickle.load","(","open","(","``","multi-ner-fast-headless.pickle","''",",","``","rb","''",")",")",">",">",">","WordEmbeddingsStore.load_stores","(","tagger",",","backend='lmdb","'",")",">",">",">","text","=","``","Schade","um","den","Ameisenb\u00e4ren",".","Lukas","B\u00e4rfuss","ver\u00f6ffentlicht","Erz\u00e4hlungen","aus","zwanzig","Jahren",".","''",">",">",">","sentence","=","Sentence","(","text",")",">",">",">","tagger.predict","(","sentence",")",">",">",">","print","(","sentence.get_spans","(","'ner","'",")",")"]
docstr: Instantiates the WordEmbeddingsStore.
  
  Args:
      embedding: The WordEmbeddings to store.
      backend: cache database backend name e.g ``'sqlite'``, ``'lmdb'``. Default value is ``'sqlite'``.
      verbose: If `True` print information on standard output
docstr_tok: ["Instantiates","the","WordEmbeddingsStore",".","Args",":","embedding",":","The","WordEmbeddings","to","store",".","backend",":","cache","database","backend","name","e.g","``","'sqlite","'","``",",","``","'lmdb","'","``",".","Default","value","is","``","'sqlite","'","``",".","verbose",":","If","`","True","`","print","information","on","standard","output"]
code: def __init__(
      self, embedding: WordEmbeddings, backend="sqlite", verbose=True
  ) -> None:
      """Instantiates the WordEmbeddingsStore.
  
      Args:
          embedding: The WordEmbeddings to store.
          backend: cache database backend name e.g ``'sqlite'``, ``'lmdb'``. Default value is ``'sqlite'``.
          verbose: If `True` print information on standard output
      """
      self.items = ""
  
      # get db filename from embedding name
      self.name = embedding.name
      self.store_path: Path = WordEmbeddingsStore._get_store_path(
          embedding, backend
      )
      if verbose:
          logger.info(f"store filename: {self.store_path!s}")
      self.backend: Union[WordEmbeddings, WordEmbeddingsStoreBackend]
      if backend == "sqlite":
          self.backend = SqliteWordEmbeddingsStoreBackend(
              embedding, verbose
          )
      elif backend == "lmdb":
          self.backend = LmdbWordEmbeddingsStoreBackend(
              embedding, verbose
          )
      else:
          raise ValueError(
              f'The given backend "{backend}" is not available.'
          )
      # In case initialization of cached version failed, just fallback to the original WordEmbeddings
      if not self.backend.is_ok:
          self.backend = WordEmbeddings(embedding.embeddings)
  
imports: import logging
  import pickle
  import re
  import shutil
  import sqlite3
  from pathlib import Path
  from typing import Union
  import numpy
  import torch
  from tqdm import tqdm
  import flair
  from flair.embeddings import WordEmbeddings
label_desc: Use image node_id 1 to create a new WordEmbeddingsStore object  with example: obj = WordEmbeddingsStore(embedding, backend, verbose)