def _binarize_chunk_and_finalize(
        cls,
        binarizer: Binarizer,
        filename: str,
        offset_start: int,
        offset_end: int,
        output_prefix: str,
        dataset_impl: str,
        vocab_size=None,
    ):
        """
        same as above, but also finalizes the builder
        """
        ds, summ = cls._binarize_file_chunk(
            binarizer,
            filename,
            offset_start,
            offset_end,
            output_prefix,
            dataset_impl,
            vocab_size=vocab_size,
        )

        idx_file = indexed_dataset.index_file_path(output_prefix)
        ds.finalize(idx_file)

        return summ

        same as above, but also finalizes the builder
        
understand_icl/fairseq/fairseq/binarizer.py