def METHOD_NAME(self):
    offsets = []
    cur_offset = 0
    passages = write_open(os.path.join(self.opts.output_dir, f'passages_{self.embed_num}_of_{self.embed_count}.json.gz.records'), binary=True)
    report = Reporting()
    doc_batch = []
    for pndx, passage in enumerate(corpus_reader(self.opts.collection, fieldnames = ('id', 'text', 'title'))):
        if pndx == 0 and (passage.pid == 'id' or passage.pid == 'pid') and (passage.text == 'text' or passage.text == 'contents') and passage.title == 'title':
            continue
        if pndx % self.embed_count != (self.embed_num-1):
            continue
        if report.is_time():
            logger.info(f'on instance {report.check_count}, {report.check_count/report.elapsed_seconds()} instances per second')
        doc_batch.append(passage)
        if len(doc_batch) == self.opts.bsize:
            embeddings = self.embed(doc_batch, self.ctx_encoder, self.ctx_tokenizer)
            cur_offset = self.write(cur_offset, offsets, passages, doc_batch, embeddings)
            doc_batch = []
    if len(doc_batch) > 0:
        embeddings = self.embed(doc_batch, self.ctx_encoder, self.ctx_tokenizer)
        cur_offset = self.write(cur_offset, offsets, passages, doc_batch, embeddings)
    offsets.append(cur_offset)  # just the length of the file
    passages.close()
    with write_open(os.path.join(self.opts.output_dir, f'offsets_{self.embed_num}_of_{self.embed_count}.npy'), binary=True) as f:
        np.save(f, np.array(offsets, dtype=np.int64), allow_pickle=False)
    logger.info(f'wrote passages_{self.embed_num}_of_{self.embed_count}.json.gz.records in {report.elapsed_time_str()}')
    #print(f'Wrote passages_{self.embed_num}_of_{self.embed_count}.json.gz.records in {report.elapsed_time_str()}')
    if self.opts.sharded_index:
        build_index(os.path.join(self.opts.output_dir, f'passages_{self.embed_num}_of_{self.embed_count}.json.gz.records'),
                    os.path.join(self.opts.output_dir, f'index_{self.embed_num}_of_{self.embed_count}.faiss'), self.opts)
    elif self.embed_count == 1:
        build_index(self.opts.output_dir, os.path.join(self.opts.output_dir, 'index.faiss'), self.opts)