class_docstr: Builds a faiss index from a data store containing stored keys (i.e., decoder hidden states for k-NN-based MT).
  
  :param config: a KNNConfig object containing the index configuration information
  :param use_gpu: build index on a gpu
  :param device_id: device id if building index on gpu
docstr: Top-level function of the class to build faiss index for a set of keys, optionally with samples for training.
docstr_tok: ["Top-level","function","of","the","class","to","build","faiss","index","for","a","set","of","keys",",","optionally","with","samples","for","training","."]
code: def build_faiss_index(
      self, keys: np.ndarray, train_sample: Optional[np.memmap] = None
  ):
      """
      Top-level function of the class to build faiss index for a set of keys, optionally with samples for training.
      """
      item_count, _ = keys.shape
      if train_sample is None and self.config.train_data_size > 0:
          train_sample = FaissIndexBuilder.build_train_sample(
              keys, self.config.train_data_size
          )
  
      index = self.init_faiss_index(train_sample)
      self.block_add_items(index, keys)
  
      return index
  
imports: from dataclasses import dataclass
  import logging
  import numpy
  import os
  import shutil
  from typing import Optional
  from .None import arguments
  from sockeye import config, utils, constants
  from sockeye.log import setup_main_logger
label_desc: Use image node_id 6 for calling the FaissIndexBuilder obj's underlying member method code with example usage: obj.build_faiss_index(keys, train_sample) and returns: index