def METHOD_NAME(self, index, embedder, text_dataset, block):
    '''Encode sub-dataset block, to be later added to index.
    Encode the data subset, generally in blocks of 1M vectors each. For
    each block, the empty/trained index is loaded, codes are computed
    via index.sa_encode(), and the resulting codes are saved to disk.
    '''
    args = get_retro_args()
    # Embed block.
    embeddings = self.embed_text_dataset_block(
        embedder,
        text_dataset,
        block["range"],
    )
    # Encode block.
    print_rank_0("encode.")
    codes = index.sa_encode(embeddings)
    # Save neighbors.
    print_rank_0("save codes.")
    os.makedirs(os.path.dirname(block["path"]), exist_ok=True)
    with h5py.File(block["path"], "w") as f:
        f.create_dataset("data", data=codes)