def METHOD_NAME(self):
    if torch.distributed.get_rank() != 0:
        return
    added_index_path = self.get_added_index_path()
    if os.path.exists(added_index_path):
        return
    args = get_retro_args()
    # Index.
    print_rank_0("read empty index.")
    index = self.get_empty_index()
    index_ivf = faiss.extract_index_ivf(index)
    # Add codes.
    print_rank_0("add codes.")
    code_paths = get_added_code_paths()
    pbar = tqdm(code_paths)
    for code_path in pbar:
        pbar.set_description("add codes, mem %.3f gb, %.1f%%" % (
            psutil.virtual_memory()[3] / 1024**3,
            psutil.virtual_memory()[2],
        ))
        with h5py.File(code_path) as f:
            nload = int(args.retro_index_add_load_fraction*f["data"].shape[0])
            offset = int(os.path.basename(code_path).split("-")[0])
            xids = np.arange(offset, offset + nload)
            codes = np.copy(f["data"][:nload])
            index_ivf.add_sa_codes(codes, xids)
    # Update index's ntotal.
    index.ntotal = index_ivf.ntotal
    # Write index.
    print_rank_0("write added index.")
    faiss.write_index(index, added_index_path)