class_docstr: Class to build and search annoy indices.
  
  TODO(b/162421415): Split the managing of indices and the index logic.
  
  Upon instantiation of this class, it will first create empty indices for
  every model/embedding/dataset triple. It will then search for existing indices
  in the data directory and fill those. If the flag `initialize_new_indices` is
  set, it will fill the remaining indices by iterating over the data.
  During the saving process, both the index and a mapping from index-row to
  example are saved. These are used during the nearest neighbor lookup to return
  the closest example.
  
  Attributes:
     models: specification akin to the LIT server.
     datasets: specification akin to the LIT server.
     data_dir: path for (de-)serialization of indices.
     initialize_new_indices: whether to build new indices or simply load
       existing ones.
docstr: If possible, load indices from file for a model/data combination.
docstr_tok: ["If","possible",",","load","indices","from","file","for","a","model\/data","combination","."]
code: def _init_index_from_file(self, model_name, dataset_name, emb_name):
      """If possible, load indices from file for a model/data combination."""
      index_key = self._get_index_key(
          model_name, dataset_name, emb_name
      )
      index_path = self._get_index_path(index_key)
      if os.path.exists(index_path):
          logging.info("Loading from cache: %s", index_path)
          self._indices[index_key].load(index_path)
          index_size = self._indices[index_key].get_n_items()
          logging.info("Loaded index with %s items.", index_size)
  
imports: import collections
  from collections.abc import Mapping
  import os
  import pickle
  from typing import Optional
  from absl import logging
  import annoy
  from lit_nlp.api import dataset
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.lib import utils
label_desc: Use image node_id 10 for calling the Indexer obj's underlying member method code with example usage: obj._init_index_from_file(model_name, dataset_name, emb_name) without return types