def chunkize_serial(iterable, chunksize, as_numpy=False):
 it = iter(iterable)
 while True:
  if as_numpy:
   wrapped_chunk = [[np.array(doc) for doc in itertools.islice(it, int(chunksize))]]
  else:
   wrapped_chunk = [list(itertools.islice(it, int(chunksize)))]
  if (not wrapped_chunk[0]):
   break
  (yield wrapped_chunk.pop())

def chunkize_serial ( iterable , chunksize , as_numpy = False ) : it = iter ( iterable ) while True : if as_numpy : wrapped_chunk = [ [ np . array ( doc ) for doc in itertools . islice ( it , int ( chunksize ) ) ] ] else : wrapped_chunk = [ list ( itertools . islice ( it , int ( chunksize ) ) ) ] if ( not wrapped_chunk [ 0 ] ) : break ( yield wrapped_chunk . pop ( ) )
return elements from the iterable in chunksize-ed lists .