class_docstr: A wrapper around an instance of [`~datasets.Datasets`]. If `index_path` is set to `None`, we load the pre-computed
  index available with the [`~datasets.arrow_dataset.Dataset`], otherwise, we load the index from the indicated path
  on disk.
  
  Args:
      vector_size (`int`): the dimension of the passages embeddings used by the index
      dataset_name (`str`, optional, defaults to `wiki_dpr`):
          A dataset identifier of the indexed dataset on HuggingFace AWS bucket (list all available datasets and ids
          with `datasets.list_datasets()`).
      dataset_split (`str`, optional, defaults to `train`)
          Which split of the `dataset` to load.
      index_name (`str`, optional, defaults to `train`)
          The index_name of the index associated with the `dataset`. The index loaded from `index_path` will be saved
          under this name.
      index_path (`str`, optional, defaults to `None`)
          The path to the serialized faiss index on disk.
      use_dummy_dataset (`bool`, optional, defaults to `False`):
          If True, use the dummy configuration of the dataset for tests.
class_docstr_tok: ["A","wrapper","around","an","instance","of","[","`","~datasets.Datasets","`","]",".","If","`","index_path","`","is","set","to","`","None","`",",","we","load","the","pre-computed","index","available","with","the","[","`","~datasets.arrow_dataset.Dataset","`","]",",","otherwise",",","we","load","the","index","from","the","indicated","path","on","disk",".","Args",":","vector_size","(","`","int","`",")",":","the","dimension","of","the","passages","embeddings","used","by","the","index","dataset_name","(","`","str","`",",","optional",",","defaults","to","`","wiki_dpr","`",")",":","A","dataset","identifier","of","the","indexed","dataset","on","HuggingFace","AWS","bucket","(","list","all","available","datasets","and","ids","with","`","datasets.list_datasets","(",")","`",")",".","dataset_split","(","`","str","`",",","optional",",","defaults","to","`","train","`",")","Which","split","of","the","`","dataset","`","to","load",".","index_name","(","`","str","`",",","optional",",","defaults","to","`","train","`",")","The","index_name","of","the","index","associated","with","the","`","dataset","`",".","The","index","loaded","from","`","index_path","`","will","be","saved","under","this","name",".","index_path","(","`","str","`",",","optional",",","defaults","to","`","None","`",")","The","path","to","the","serialized","faiss","index","on","disk",".","use_dummy_dataset","(","`","bool","`",",","optional",",","defaults","to","`","False","`",")",":","If","True",",","use","the","dummy","configuration","of","the","dataset","for","tests","."]
code: def init_index(self):
      if self.index_path is not None:
          logger.info(f"Loading index from {self.index_path}")
          self.dataset.load_faiss_index(
              "embeddings", file=self.index_path
          )
      else:
          logger.info(
              f"Loading index from {self.dataset_name} with index name {self.index_name}"
          )
          self.dataset = load_dataset(
              self.dataset_name,
              with_embeddings=True,
              with_index=True,
              split=self.dataset_split,
              index_name=self.index_name,
              dummy=self.use_dummy_dataset,
          )
          self.dataset.set_format(
              "numpy", columns=["embeddings"], output_all_columns=True
          )
      self._index_initialized = True
  
imports: import os
  import pickle
  import time
  from typing import Iterable, List, Optional, Tuple
  import numpy
  from ...tokenization_utils import PreTrainedTokenizer
  from ...tokenization_utils_base import BatchEncoding
  from ...utils import cached_file, is_datasets_available, is_faiss_available, logging, requires_backends
  from .configuration_rag import RagConfig
  from .tokenization_rag import RagTokenizer
label_desc: Use image node_id 2 for calling the CanonicalHFIndex obj's underlying member method code with example usage: obj.init_index() without return types