(it: Iterable[_T], max_len: int)
return (
        (y for _, y in x)
        for _, x in itertools.groupby(enumerate(it), key=lambda x: int(x[0] / max_len))
    )
Batches an iterator in iterators of a maximum length

    :param it: The iterator to batch
    :param max_len: The maximum length
Batches an iterator in iterators of a maximum length
Batches an iterator in iterators of a maximum length
def batched(it: Iterable[_T], max_len: int) -> Iterator[Iterator[_T]]:
    """
    Batches an iterator in iterators of a maximum length

    :param it: The iterator to batch
    :param max_len: The maximum length
    """
    return (
        (y for _, y in x)
        for _, x in itertools.groupby(enumerate(it), key=lambda x: int(x[0] / max_len))
    )
def batched ( it : Iterable [ _T ] , max_len : int ) -> Iterator [ Iterator [ _T ] ] : return ( ( y for _ , y in x ) for _ , x in itertools . groupby ( enumerate ( it ) , key = lambda x : int ( x [ 0 ] / max_len ) ) )