class_docstr: This class allows the use of `Annoy <https://github.com/spotify/annoy>`_ for fast (approximate)
  vector retrieval in `most_similar()` calls of
  :class:`~gensim.models.word2vec.Word2Vec`, :class:`~gensim.models.doc2vec.Doc2Vec`,
  :class:`~gensim.models.fasttext.FastText` and :class:`~gensim.models.keyedvectors.Word2VecKeyedVectors` models.
class_docstr_tok: ["This","class","allows","the","use","of","`","Annoy","<","https",":","\/\/github.com\/spotify\/annoy",">","`","_","for","fast","(","approximate",")","vector","retrieval","in","`","most_similar","(",")","`","calls","of",":","class",":","`","~gensim.models.word2vec.Word2Vec","`",",",":","class",":","`","~gensim.models.doc2vec.Doc2Vec","`",",",":","class",":","`","~gensim.models.fasttext.FastText","`","and",":","class",":","`","~gensim.models.keyedvectors.Word2VecKeyedVectors","`","models","."]
docstr: Load an AnnoyIndexer instance from disk.
  
  Parameters
  ----------
  fname : str
      The path as previously used by ``save()``.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.similarities.index import AnnoyIndexer
      >>> from gensim.models import Word2Vec
      >>> from tempfile import mkstemp
      >>>
      >>> sentences = [['cute', 'cat', 'say', 'meow'], ['cute', 'dog', 'say', 'woof']]
      >>> model = Word2Vec(sentences, min_count=1, seed=1, epochs=10)
      >>>
      >>> indexer = AnnoyIndexer(model, 2)
      >>> _, temp_fn = mkstemp()
      >>> indexer.save(temp_fn)
      >>>
      >>> new_indexer = AnnoyIndexer()
      >>> new_indexer.load(temp_fn)
      >>> new_indexer.model = model
docstr_tok: ["Load","an","AnnoyIndexer","instance","from","disk",".","Parameters","--","--","--","--","--","fname",":","str","The","path","as","previously","used","by","``","save","(",")","``",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.similarities.index","import","AnnoyIndexer",">",">",">","from","gensim.models","import","Word2Vec",">",">",">","from","tempfile","import","mkstemp",">",">",">",">",">",">","sentences","=","[","[","'cute","'",",","'cat","'",",","'say","'",",","'meow","'","]",",","[","'cute","'",",","'dog","'",",","'say","'",",","'woof","'","]","]",">",">",">","model","=","Word2Vec","(","sentences",",","min_count=1",",","seed=1",",","epochs=10",")",">",">",">",">",">",">","indexer","=","AnnoyIndexer","(","model",",","2",")",">",">",">","_",",","temp_fn","=","mkstemp","(",")",">",">",">","indexer.save","(","temp_fn",")",">",">",">",">",">",">","new_indexer","=","AnnoyIndexer","(",")",">",">",">","new_indexer.load","(","temp_fn",")",">",">",">","new_indexer.model","=","model"]
code: def load(self, fname):
      """Load an AnnoyIndexer instance from disk.
  
      Parameters
      ----------
      fname : str
          The path as previously used by ``save()``.
  
      Examples
      --------
      .. sourcecode:: pycon
  
          >>> from gensim.similarities.index import AnnoyIndexer
          >>> from gensim.models import Word2Vec
          >>> from tempfile import mkstemp
          >>>
          >>> sentences = [['cute', 'cat', 'say', 'meow'], ['cute', 'dog', 'say', 'woof']]
          >>> model = Word2Vec(sentences, min_count=1, seed=1, epochs=10)
          >>>
          >>> indexer = AnnoyIndexer(model, 2)
          >>> _, temp_fn = mkstemp()
          >>> indexer.save(temp_fn)
          >>>
          >>> new_indexer = AnnoyIndexer()
          >>> new_indexer.load(temp_fn)
          >>> new_indexer.model = model
  
      """
      fname_dict = fname + ".dict"
      if not (os.path.exists(fname) and os.path.exists(fname_dict)):
          raise IOError(
              f"Can't find index files '{fname}' and '{fname_dict}' - unable to restore AnnoyIndexer state."
          )
      try:
          from annoy import AnnoyIndex
      except ImportError:
          raise _NOANNOY
  
      with utils.open(fname_dict, "rb") as f:
          d = _pickle.loads(f.read())
      self.num_trees = d["num_trees"]
      self.index = AnnoyIndex(d["f"], metric="angular")
      self.index.load(fname)
      self.labels = d["labels"]
  
file_path: gensim/gensim/similarities/annoy.py
imports: from __future__ import absolute_import
  import os
  from gensim import utils
  from gensim.models.doc2vec import Doc2Vec
  from gensim.models.word2vec import Word2Vec
  from gensim.models.fasttext import FastText
  from gensim.models import KeyedVectors
label_desc: Use image node_id 3 for calling the AnnoyIndexer obj's underlying member method code with example usage: obj.load(fname) without return types