MCPcopy Create free account
hub / github.com/MiniMax-AI/VTP / batched

Function batched

tools/test_zero_shot_hf.py:302–309  ·  view source on GitHub ↗

Batch data into lists of length n. The last batch may be shorter.

(iterable, n: int)

Source from the content-addressed store, hash-verified

300# ============================================================================
301
302def batched(iterable, n: int):
303 """Batch data into lists of length n. The last batch may be shorter."""
304 it = iter(iterable)
305 while True:
306 batch = list(islice(it, n))
307 if not batch:
308 break
309 yield batch
310
311
312def accuracy(output: torch.Tensor, target: torch.Tensor, topk: Tuple[int, ...] = (1,)) -> List[float]:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected