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__(
      self,
      vector_size: int,
      dataset_name: str = "wiki_dpr",
      dataset_split: str = "train",
      index_name: Optional[str] = None,
      index_path: Optional[str] = None,
      use_dummy_dataset=False,
  ):
      if int(index_path is None) + int(index_name is None) != 1:
          raise ValueError(
              "Please provide `index_name` or `index_path`."
          )
      self.dataset_name = dataset_name
      self.dataset_split = dataset_split
      self.index_name = index_name
      self.index_path = index_path
      self.use_dummy_dataset = use_dummy_dataset
      logger.info(f"Loading passages from {self.dataset_name}")
      dataset = load_dataset(
          self.dataset_name,
          with_index=False,
          split=self.dataset_split,
          dummy=self.use_dummy_dataset,
      )
      super().__init__(vector_size, dataset, index_initialized=False)
  
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, strtobool
  from .configuration_rag import RagConfig
  from .tokenization_rag import RagTokenizer
label_desc: Use image node_id 1 to create a new CanonicalHFIndex object from inherited base classes: HFIndexBase with example: obj = CanonicalHFIndex(vector_size, dataset_name, dataset_split, index_name, index_path, use_dummy_dataset)