class_docstr: Class to imitate gensim's KeyedVectors, but instead getting the vectors from the memory,
  the vectors will be retrieved from a redis db.
  Based on https://engineering.talentpair.com/serving-word-vectors-
  for-distributed-computations-c5065cbaa02f
class_docstr_tok: ["Class","to","imitate","gensim","'s","KeyedVectors",",","but","instead","getting","the","vectors","from","the","memory",",","the","vectors","will","be","retrieved","from","a","redis","db",".","Based","on","https",":","\/\/engineering.talentpair.com\/serving-word-vectors-","for-distributed-computations-c5065cbaa02f"]
docstr: This function loops over all available words in the loaded word2vec keyed vectors model
  and loads them into the redis instance.
docstr_tok: ["This","function","loops","over","all","available","words","in","the","loaded","word2vec","keyed","vectors","model","and","loads","them","into","the","redis","instance","."]
code: def load_keyed_vectors_into_redis(
      self, model_path, idf_weighting="naive"
  ):
      """
      This function loops over all available words in the loaded word2vec keyed vectors model
      and loads them into the redis instance.
      """
      model = KeyedVectors.load(model_path, mmap="r")
      nr_train_tokens = sum(
          token_vocab.count for token_vocab in model.vocab.values()
      )
      self.idf_weighting = idf_weighting
      try:
          for word in tqdm(list(model.vocab.keys())):
              if self.idf_weighting == "naive":
                  idf = model.vocab[word].count
              elif self.idf_weighting == "log":
                  idf = (
                      np.log(
                          nr_train_tokens
                          / (model.vocab[word].count + 1)
                      )
                      + 1
                  )
              else:
                  raise ValueError(
                      f'idf_weighting "{self.idf_weighting}" not available; use '
                      f'"naive" or "log"'
                  )
              idf_normalized_vector = model[word] / idf
              self._redis.hset(
                  self.key, word, pickle.dumps(idf_normalized_vector)
              )
      except RedisError as exception:
          # pylint: disable=raise-missing-from
          raise RedisKeyedVectorException(
              f"RedisError while trying to load model {model} "
              f"into redis: {exception}"
          )
      del model
  
file_path: textpipe/textpipe/wrappers.py
imports: import pickle
  from functools import lru_cache
  from urllib.parse import urlparse
  import numpy
  from gensim.models.keyedvectors import KeyedVectors
  from redis import Redis
  from redis.exceptions import RedisError
  from tqdm import tqdm
label_desc: Use image node_id 5 for calling the RedisKeyedVectors obj's underlying member method code with example usage: obj.load_keyed_vectors_into_redis(model_path, idf_weighting) without return types