class_docstr: Extend the IterableDataset with a buffer and randomly pop items.
  
  Args:
      data: input data source to load and transform to generate dataset for model.
      transform: a callable data transform on input data.
      buffer_size: size of the buffer to store items and randomly pop, default to 512.
      seed: random seed to initialize the random state of all workers, set `seed += 1` in
          every iter() call, refer to the PyTorch idea:
          https://github.com/pytorch/pytorch/blob/v1.10.0/torch/utils/data/distributed.py#L98.
      epochs: number of epochs to iterate over the dataset, default to 1, -1 means infinite epochs.
  
  Note:
      Both ``monai.data.DataLoader`` and ``torch.utils.data.DataLoader`` do not seed this class (as a subclass of
      ``IterableDataset``) at run time. ``persistent_workers=True`` flag (and pytorch>1.8) is therefore required
      for multiple epochs of loading when ``num_workers>0``. For example::
  
          import monai
  
          def run():
              dss = monai.data.ShuffleBuffer([1, 2, 3, 4], buffer_size=30, seed=42)
  
              dataloader = monai.data.DataLoader(
                  dss, batch_size=1, num_workers=2, persistent_workers=True)
              for epoch in range(3):
                  for item in dataloader:
                      print(f"epoch: {epoch} item: {item}.")
  
          if __name__ == '__main__':
              run()
class_docstr_tok: ["Extend","the","IterableDataset","with","a","buffer","and","randomly","pop","items",".","Args",":","data",":","input","data","source","to","load","and","transform","to","generate","dataset","for","model",".","transform",":","a","callable","data","transform","on","input","data",".","buffer_size",":","size","of","the","buffer","to","store","items","and","randomly","pop",",","default","to","512.","seed",":","random","seed","to","initialize","the","random","state","of","all","workers",",","set","`","seed","+=","1","`","in","every","iter","(",")","call",",","refer","to","the","PyTorch","idea",":","https",":","\/\/github.com\/pytorch\/pytorch\/blob\/v1.10.0\/torch\/utils\/data\/distributed.py","#","L98",".","epochs",":","number","of","epochs","to","iterate","over","the","dataset",",","default","to","1",",","-1","means","infinite","epochs",".","Note",":","Both","``","monai.data.DataLoader","``","and","``","torch.utils.data.DataLoader","``","do","not","seed","this","class","(","as","a","subclass","of","``","IterableDataset","``",")","at","run","time",".","``","persistent_workers=True","``","flag","(","and","pytorch",">","1.8",")","is","therefore","required","for","multiple","epochs","of","loading","when","``","num_workers",">","0","``",".","For","example",":",":","import","monai","def","run","(",")",":","dss","=","monai.data.ShuffleBuffer","(","[","1",",","2",",","3",",","4","]",",","buffer_size=30",",","seed=42",")","dataloader","=","monai.data.DataLoader","(","dss",",","batch_size=1",",","num_workers=2",",","persistent_workers=True",")","for","epoch","in","range","(","3",")",":","for","item","in","dataloader",":","print","(","f","''","epoch",":","{","epoch","}","item",":","{","item","}",".","''",")","if","__name__","==","'__main__","'",":","run","(",")"]
code: def randomize(self, size: int) -> None:
      self._idx = self.R.randint(size)
  
imports: from __future__ import annotations
  from collections.abc import Callable, Iterable, Iterator, Sequence
  from typing import Any
  from torch.utils.data import IterableDataset
  from torch.utils.data import get_worker_info
  from monai.data.utils import convert_tables_to_dicts
  from monai.transforms import apply_transform
  from monai.transforms.transform import Randomizable
  from monai.utils import optional_import
label_desc: Use image node_id 5 for calling the ShuffleBuffer obj's underlying member method code with example usage: obj.randomize(size) without return types