original_docstring: Returns one chunk of the given iterable at a time
docstring: Returns one chunk of the given iterable at a time
docstring_tokens: Returns one chunk of the given iterable at a time
code: def chunked(iterable: tp.Iterable[VALUE], chunk_size: int) -> tp.Iterator[tp.List[VALUE]]:
      """Returns one chunk of the given iterable at a time"""
      # we need to be sure that we store an iterator in closure in order to keep
      # the state of iteration
      iterable = iter(iterable)
      def wrapper() -> tp.List[VALUE]:
          # we need a closure to save state of iterator, otherwise it will
          # always start over and return first n elements on every call
          return list(islice(iterable, chunk_size))
      # The second argument of iter is what will return on stop iteration.
      return iter(wrapper, [])
code_tokens: def chunked ( iterable : tp . Iterable [ VALUE ] , chunk_size : int ) -> tp . Iterator [ tp . List [ VALUE ] ] : iterable = iter ( iterable ) def wrapper ( ) -> tp . List [ VALUE ] : return list ( islice ( iterable , chunk_size ) ) return iter ( wrapper , [ ] )
short_docstring: Returns one chunk of the given iterable at a time
short_docstring_tokens: Returns one chunk of the given iterable at a time
comment: """Returns one chunk of the given iterable at a time"""$SEP$# we need to be sure that we store an iterator in closure in order to keep$SEP$# the state of iteration$SEP$# we need a closure to save state of iterator, otherwise it will$SEP$# always start over and return first n elements on every call$SEP$# The second argument of iter is what will return on stop iteration.