def _batch_questions(self, questions: List[Tuple[QASetting, List[Answer]]], batch_size, is_eval: bool):
"""Optionally shuffles and batches annotations.
By default, all annotations are shuffled (if self.shuffle(is_eval) and
then batched. Override this method if you want to customize the
batching, e.g., to do stratified sampling, sampling with replacement,
etc.
Args:
- annotations: List of annotations to shuffle & batch.
- is_eval: Whether batches are generated for evaluation.
Returns: Batch iterator
"""
rng = _rng if self._shuffle(is_eval) else None
return shuffle_and_batch(questions, batch_size, rng)
评论列表
文章目录