def _chunked(iterable, n):
it = iter(iterable)<EOL>while True:<EOL><INDENT>chunk = list(islice(it, n))<EOL>if chunk:<EOL><INDENT>yield chunk<EOL><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT><DEDENT>
Collect data into chunks of up to length n.
:type iterable: Iterable[T]
:type n: int
:rtype: Iterator[list[T]]