splits iterables a in equal parts of size sz
767677
def partition(a, sz): 
    """"""
    return [a[i:i+sz] for i in range(0, len(a), sz)]
245319
def split_every(parts, iterable):
    
    return takewhile(bool, (list(islice(iterable, parts)) for _ in count()))
810174
def batch_iterable(l, n):
    ''' '''
    i = iter(l)
    piece = list(islice(i, n))
    while piece:
        yield piece
        piece = list(islice(i, n))
1163112
def window(iterable, size=2):
    '''  '''
    iterable = iter(iterable)
    d = deque(islice(iterable, size-1), maxlen=size)
    for _ in map(d.append, iterable):
        yield tuple(d)
1356863
def _slice(index, n_samples, margin=None):
    """"""
    if margin is None:
        margin = (0, 0)
    assert isinstance(n_samples, (tuple, list))
    assert len(n_samples) == 2
    before, after = n_samples
    assert isinstance(margin, (tuple, list))
    assert len(margin) == 2
    margin_before, margin_after = margin
    before += margin_before
    after += margin_after
    index = int(index)
    before = int(before)
    after = int(after)
    return slice(max(0, index - before), index + after, None)
39203
def chunks(iterable, size = 8):
	
	for i in range(0, len(iterable), size):
		yield l[i:i + n]
1133682
def splits(self):
        
        return list(map(lambda x: self.select_code(x), self.code))
173448
def slice_into_pieces(seq, n):
    """"""
    length = len(seq)
    if length % n == 0:
        size = length // n
    else:
        size = length // n + 1
    for it in slice_by_size(seq, size):
        yield it
19470
private static Iterable<List<Map.Entry<Symbol, File>>> splitToNChunks(
      final ImmutableMap<Symbol, File> inputMap, int numChunks) {
    checkArgument(numChunks > 0);
    final List<Map.Entry<Symbol, File>> emptyChunk = ImmutableList.of();

    if (inputMap.isEmpty()) {
      return Collections.nCopies(numChunks, emptyChunk);
    }

    final int chunkSize = IntMath.divide(inputMap.size(), numChunks, RoundingMode.UP);
    final ImmutableList<List<Map.Entry<Symbol, File>>> chunks =
        ImmutableList.copyOf(splitToChunksOfFixedSize(inputMap, chunkSize));
    if (chunks.size() == numChunks) {
      return chunks;
    } else {
      // there weren't enough elements to make the desired number of chunks, so we need to
      // pad with empty chunks
      final int shortage = numChunks - chunks.size();
      final List<List<Map.Entry<Symbol, File>>> padding = Collections.nCopies(shortage, emptyChunk);
      return Iterables.concat(chunks, padding);
    }
  }
906016
def possiblesplits(n, minsplits=2, maxsplits=0):
    """"""
    if not maxsplits: maxsplits = n
    for nrsplits in range(minsplits,maxsplits + 1):
        for split in sum_to_n(n,nrsplits):
            split_with_indices = []
            begin = 0
            for length in split:
                split_with_indices.append( (begin, length) )
                begin += length
            yield split_with_indices
936769
def pairwise(iterable):
    """"""
    first, second = tee(iterable)
    next(second, None)
    return zip(first, second)
913887
def split_in_pairs(arg: Iterable) -> Iterable[Tuple]:
    
    # We are using zip_longest with one clever hack:
    # https://docs.python.org/3/library/itertools.html#itertools.zip_longest
    # We create an iterator out of the list and then pass the same iterator to
    # the function two times. Thus the function consumes a different element
    # from the iterator each time and produces the desired result.
    iterator = iter(arg)
    return zip_longest(iterator, iterator)
1240586
def chunked(iterable, n):

    
    iterable = iter(iterable)
    while 1:
        t = tuple(islice(iterable, n))
        if t:
            yield t
        else:
            return
364631
public static <T> List<T> split( Iterable<T> objects, boolean even )
    {
        List<T> parts = new ArrayList<T>();
        for (T element : objects)
        {
            if (even) parts.add( element );
            even = !even;
        }
        return parts;
    }
618338
def stretch(iterable, n=2):
    
    """
    times = range(n)
    for item in iterable:
        for i in times: yield item
145692
def chunks(iterable, size=100):
    
    it = iter(iterable)
    size -= 1
    for head in it:
        yield itertools.chain([head], itertools.islice(it, size))
1112883
def chunks(some_list: List, n: int) -> Iterable[List]:
    """"""
    for i in range(0, len(some_list), n):
        yield some_list[i:i + n]