async def aget_text_embedding_batch(
        self, texts: List[str], show_progress: bool = False
    ) -> List[SparseEmbedding]:
        """Asynchronously get a list of text embeddings, with batching."""
        num_workers = self.num_workers

        model_dict = self.model_dump()

        cur_batch: List[str] = []
        callback_payloads: List[List[str]] = []
        result_embeddings: List[SparseEmbedding] = []
        embeddings_coroutines: List[Coroutine] = []
        for idx, text in enumerate(texts):
            cur_batch.append(text)
            if idx == len(texts) - 1 or len(cur_batch) == self.embed_batch_size:
                # flush
                dispatcher.event(
                    SparseEmbeddingStartEvent(
                        model_dict=model_dict,
                    )
                )

                callback_payloads.append(cur_batch)
                embeddings_coroutines.append(self._aget_text_embeddings(cur_batch))
                cur_batch = []

        # flatten the results of asyncio.gather, which is a list of embeddings lists
        nested_embeddings = []

        if num_workers and num_workers > 1:
            nested_embeddings = await run_jobs(
                embeddings_coroutines,
                show_progress=show_progress,
                workers=self.num_workers,
                desc="Generating embeddings",
            )
        else:
            if show_progress:
                try:
                    from tqdm.asyncio import tqdm_asyncio

                    nested_embeddings = await tqdm_asyncio.gather(
                        *embeddings_coroutines,
                        total=len(embeddings_coroutines),
                        desc="Generating embeddings",
                    )
                except ImportError:
                    nested_embeddings = await asyncio.gather(*embeddings_coroutines)
            else:
                nested_embeddings = await asyncio.gather(*embeddings_coroutines)

        result_embeddings = [
            embedding for embeddings in nested_embeddings for embedding in embeddings
        ]

        for text_batch, embeddings in zip(callback_payloads, nested_embeddings):
            dispatcher.event(
                SparseEmbeddingEndEvent(
                    chunks=text_batch,
                    embeddings=embeddings,
                )
            )

        return result_embeddings
Asynchronously get a list of text embeddings, with batching.
llama-index-core/llama_index/core/base/embeddings/base_sparse.py