code: def batch(batch_size, items):
      "Batch items into groups of batch_size"
      items = list(items)
      if batch_size is None:
          return [items]
      MISSING = object()
      padded_items = items + [MISSING] * (batch_size - 1)
      groups = zip(*[padded_items[i::batch_size] for i in range(batch_size)])
      return [[item for item in group if item != MISSING] for group in groupsf batch(batch_size, items):
      "Batch items into groups of batch_size"
      items = list(items)
      if batch_size is None:
          return [items]
      MISSING = object()
      padded_items = items + [MISSING] * (batch_size - 1)
      groups = zip(*[padded_items[i::batch_size] for i in range(batch_size)])
      return [[item for item in group if item != MISSING] for group in groups]
docs: Batch items into groups of batch_size