def as_chunks(iterator: _Iter[T], max_size: int) -> _Iter[List[T]]:
    'A helper function that collects an iterator into chunks of a given size.\n\n    .. versionadded:: 2.0\n\n    Parameters\n    ----------\n    iterator: Union[:class:`collections.abc.Iterator`, :class:`collections.abc.AsyncIterator`]\n        The iterator to chunk, can be sync or async.\n    max_size: :class:`int`\n        The maximum chunk size.\n\n\n    .. warning::\n\n        The last chunk collected may not be as large as ``max_size``.\n\n    Returns\n    --------\n    Union[:class:`Iterator`, :class:`AsyncIterator`]\n        A new iterator which yields chunks of a given size.\n    '
    if (max_size <= 0):
        raise ValueError('Chunk sizes must be greater than 0.')
    if isinstance(iterator, AsyncIterator):
        return _achunk(iterator, max_size)
    return _chunk(iterator, max_size)
A helper function that collects an iterator into chunks of a given size.

.. versionadded:: 2.0

Parameters
----------
iterator: Union[:class:`collections.abc.Iterator`, :class:`collections.abc.AsyncIterator`]
    The iterator to chunk, can be sync or async.
max_size: :class:`int`
    The maximum chunk size.


.. warning::

    The last chunk collected may not be as large as ``max_size``.

Returns
--------
Union[:class:`Iterator`, :class:`AsyncIterator`]
    A new iterator which yields chunks of a given size.
def as_chunks(iterator: _Iter[T], max_size: int) -> _Iter[List[T]]:
    'A helper function that collects an iterator into chunks of a given size.\n\n    .. versionadded:: 2.0\n\n    Parameters\n    ----------\n    iterator: Union[:class:`collections.abc.Iterator`, :class:`collections.abc.AsyncIterator`]\n        The iterator to chunk, can be sync or async.\n    max_size: :class:`int`\n        The maximum chunk size.\n\n\n    .. warning::\n\n        The last chunk collected may not be as large as ``max_size``.\n\n    Returns\n    --------\n    Union[:class:`Iterator`, :class:`AsyncIterator`]\n        A new iterator which yields chunks of a given size.\n    '
    if (max_size <= 0):
        raise ValueError('Chunk sizes must be greater than 0.')
    if isinstance(iterator, AsyncIterator):
        return _achunk(iterator, max_size)
    return _chunk(iterator, max_size)