MCPcopy Create free account
hub / github.com/AnswerDotAI/ModernBERT / batched

Function batched

tests/test_sequence_packer.py:25–31  ·  view source on GitHub ↗
(iterable, n)

Source from the content-addressed store, hash-verified

23
24
25def batched(iterable, n):
26 # batched('ABCDEFG', 3) → ABC DEF G
27 if n < 1:
28 raise ValueError("n must be at least one")
29 iterator = iter(iterable)
30 while batch := list(itertools.islice(iterator, n)):
31 yield batch
32
33
34xs = [

Callers 4

test_packerFunction · 0.85
test_packer_maskingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected