spdl.source.utils.embed_shuffle¶
- embed_shuffle(src: SizedIterableWithShuffle[T], /, *, shuffle_last: bool = False, epoch: int = 0) SizedIterable[T][source]¶
- embed_shuffle(src: IterableWithShuffle[T], /, *, shuffle_last: bool = False, epoch: int = 0) Iterable[T]
[Experimental] Convert
IterableWithShuffletoIterableby 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
shufflemethod.shuffle_last – If
False(default), thenshuffleis called before the iteration. Other wiseshuffleis called at the end of iteration.epoch – The initial seed value passed to
shuffle().