spdl.source.utils.embed_shuffle¶
- embed_shuffle(src: IterableWithShuffle[T], /, *, shuffle_last: bool = False, epoch: int = 0) Iterable[T] [source]¶
[Experimental] Convert
IterableWithShuffle
toIterable
by embedding theshuffle()
call into__iter__()
.Roughly equivalent to the following code snippet.
while True: if not shuffle_last: src.shuffle(seed=epoch) yield from src epoch += 1 if shuffle_last: src.shuffle(seed=epoch)
- Parameters:
src – The original iterable with
shuffle
method.shuffle_last – If
False
(default), thenshuffle
is called before the iteration. Other wiseshuffle
is called at the end of iteration.epoch – The initial seed value passed to
shuffle()
.