def batched(iterable, n):
    """Batch data into lists of length *n*. The last batch may be shorter.

    >>> list(batched('ABCDEFG', 3))
    [['A', 'B', 'C'], ['D', 'E', 'F'], ['G']]

    This recipe is from the ``itertools`` docs. This library also provides
    :func:`chunked`, which has a different implementation.
    """
    if hexversion >= 0x30C00A0:  # Python 3.12.0a0
        warnings.warn(
            (
                'batched will be removed in a future version of '
                'more-itertools. Use the standard library '
                'itertools.batched function instead'
            ),
            DeprecationWarning,
        )

    it = iter(iterable)
    while True:
        batch = list(islice(it, n))
        if not batch:
            break
        yield batch
Batch data into lists of length *n*. The last batch may be shorter.

    >>> list(batched('ABCDEFG', 3))
    [['A', 'B', 'C'], ['D', 'E', 'F'], ['G']]

    This recipe is from the ``itertools`` docs. This library also provides
    :func:`chunked`, which has a different implementation.
    
product/runtime/src/main/python/pkg_resources/_vendor/more_itertools/recipes.py