MCPcopy Create free account
hub / github.com/google-research/language / batch

Function batch

language/realm/example_generator.py:185–194  ·  view source on GitHub ↗

Groups examples into batches, dropping remainder.

(iterable, batch_size)

Source from the content-addressed store, hash-verified

183
184
185def batch(iterable, batch_size):
186 """Groups examples into batches, dropping remainder."""
187 if batch_size < 1:
188 raise ValueError('batch_size must be a positive integer.')
189 item_batch = []
190 for item in iterable:
191 item_batch.append(item)
192 if len(item_batch) == batch_size:
193 yield item_batch
194 item_batch = []
195
196
197@profile.profiled_function

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…