class_docstr: Loads samples from a dataset and combines them into batches. Can be directly passed to `Model.fit()`
class_docstr_tok: ["Loads","samples","from","a","dataset","and","combines","them","into","batches",".","Can","be","directly","passed","to","`","Model.fit","(",")","`"]
docstr: Arguments:
      dataset: The dataset from which to load samples.
               A subclass of elegy.data.Dataset or an iterable which implements `__getitem__` and `__len__`.
      batch_size: A positive integer specifying how many samples a batch should have.
      n_workers: The number of parallel worker threads or processes which load data from the dataset.
                 A value of 0 (default) means to load data from the main thread.
      shuffle: Whether to load the samples in random order or not. Reshuffles on every epoch if True. Default: False
      worker_type: One of 'thread' (default), 'process', 'spawn', 'fork' or 'forkserver'. Only used if `n_workers`>0.
                   Threads are light-weight but underly the limitations of Python's global interpreter lock.
                   'process' uses the default process type as defined in the `multiprocessing` module.
                   'spawn', 'fork' and 'forkserver' can be used to select a specific process type.
                   For more information consult the Python `multiprocessing` documentation.
      prefetch: Number of batches to prefetch for pipelined execution (Default: 2)
      timeout: Timeout in seconds for waiting for a batch of samples from worker threads.
docstr_tok: ["Arguments",":","dataset",":","The","dataset","from","which","to","load","samples",".","A","subclass","of","elegy.data.Dataset","or","an","iterable","which","implements","`","__getitem__","`","and","`","__len__","`",".","batch_size",":","A","positive","integer","specifying","how","many","samples","a","batch","should","have",".","n_workers",":","The","number","of","parallel","worker","threads","or","processes","which","load","data","from","the","dataset",".","A","value","of","0","(","default",")","means","to","load","data","from","the","main","thread",".","shuffle",":","Whether","to","load","the","samples","in","random","order","or","not",".","Reshuffles","on","every","epoch","if","True",".","Default",":","False","worker_type",":","One","of","'thread","'","(","default",")",",","'process","'",",","'spawn","'",",","'fork","'","or","'forkserver","'",".","Only","used","if","`","n_workers","`",">","0",".","Threads","are","light-weight","but","underly","the","limitations","of","Python","'s","global","interpreter","lock",".","'process","'","uses","the","default","process","type","as","defined","in","the","`","multiprocessing","`","module",".","'spawn","'",",","'fork","'","and","'forkserver","'","can","be","used","to","select","a","specific","process","type",".","For","more","information","consult","the","Python","`","multiprocessing","`","documentation",".","prefetch",":","Number","of","batches","to","prefetch","for","pipelined","execution","(","Default",":","2",")","timeout",":","Timeout","in","seconds","for","waiting","for","a","batch","of","samples","from","worker","threads","."]
code: def __init__(
      self,
      dataset: Dataset,
      batch_size: int,
      n_workers: tp.Optional[int] = 0,
      shuffle: tp.Optional[bool] = False,
      worker_type: tp.Optional[str] = "thread",
      prefetch: tp.Optional[int] = 1,
      timeout: int = 10,
  ):
      """
      Arguments:
          dataset: The dataset from which to load samples.
                   A subclass of elegy.data.Dataset or an iterable which implements `__getitem__` and `__len__`.
          batch_size: A positive integer specifying how many samples a batch should have.
          n_workers: The number of parallel worker threads or processes which load data from the dataset.
                     A value of 0 (default) means to load data from the main thread.
          shuffle: Whether to load the samples in random order or not. Reshuffles on every epoch if True. Default: False
          worker_type: One of 'thread' (default), 'process', 'spawn', 'fork' or 'forkserver'. Only used if `n_workers`>0.
                       Threads are light-weight but underly the limitations of Python's global interpreter lock.
                       'process' uses the default process type as defined in the `multiprocessing` module.
                       'spawn', 'fork' and 'forkserver' can be used to select a specific process type.
                       For more information consult the Python `multiprocessing` documentation.
          prefetch: Number of batches to prefetch for pipelined execution (Default: 2)
          timeout: Timeout in seconds for waiting for a batch of samples from worker threads.
      """
      assert (
          batch_size > 0 and type(batch_size) == int
      ), "batch_size must be a positive integer"
      assert worker_type in [
          "thread",
          "process",
          "spawn",
          "fork",
          "forkserver",
      ]
      assert (
          prefetch >= 0 and type(prefetch) == int
      ), "prefetch must be a non-negative integer"
  
      self.dataset = dataset
      self.batch_size = batch_size
      self.n_workers = n_workers
      self.shuffle = shuffle
      self.worker_type = worker_type
      self.prefetch = prefetch
      self.timeout = timeout
  
imports: import multiprocessing.pool
  import os
  import typing
  import jax
  import jax.numpy
  import numpy
  from .data_adapter import DataAdapter
  from .utils import is_none_or_empty
label_desc: Use image node_id 1 to create a new DataLoader object  with example: obj = DataLoader(dataset, batch_size, n_workers, shuffle, worker_type, prefetch, timeout)