This is code extracted from the original FAISS repository: https://github.com/facebookresearch/faiss