def batch(iterable, batch_size):
  """Groups examples into batches, dropping remainder."""
  if batch_size < 1:
    raise ValueError('batch_size must be a positive integer.')
  item_batch = []
  for item in iterable:
    item_batch.append(item)
    if len(item_batch) == batch_size:
      yield item_batch
      item_batch = []
Groups examples into batches, dropping remainder.
language/realm/example_generator.py