zigzag_product
zigzag_product(*iterables, iterator_lengths=None, return_index=False):
LLM Docstring
Enumerate a Cartesian product while reversing selected axes to create a serpentine order.
Inputs are materialized, optionally taking only the supplied iterator_lengths. As the ordinary multi-index advances, axis-direction flags are toggled when trailing indices reset to zero.
iterables:collections.abc.IterableInput iterables forming the Cartesian product.
iterator_lengths:collections.abc.Iterable[int | None] | NoneOptional lengths used both to limit materialization and reflect indices.
return_index:boolWhether to yield each value tuple together with its selected index tuple.
:returns:collections.abc.IteratorIterator over value tuples or
(values, indices)pairs.