def retrieve_all(self,
                   examples: Iterable[Example]) -> Iterator[RetrievalResult]:
    """Batches the examples, retrieves the neighbors, and yields the results."""
    batch = []
    for example in examples:
      batch.append(example)
      if len(batch) == self._batch_size:
        for result in self.retrieve_batch(batch):
          yield result
        batch = []
    # For the final batch
    if batch:
      for result in self.retrieve_batch(batch):
        yield result
Batches the examples, retrieves the neighbors, and yields the results.
language/casper/retrieve/query_retrievers.py