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: Returns a generator which generates batches of loaded data samples
docstr_tok: ["Returns","a","generator","which","generates","batches","of","loaded","data","samples"]
code: def __iter__(self) -> tp.Generator[tp.Any, None, None]:
      """Returns a generator which generates batches of loaded data samples"""
      indices = np.arange(len(self.dataset))
      if self.shuffle:
          np.random.shuffle(indices)
  
      batched_indices = [
          indices[i:][: self.batch_size]
          for i in range(0, len(indices), self.batch_size)
      ]
  
      if self.n_workers == 0:
          return mainthread_data_iterator(self.dataset, batched_indices)
      else:
          return MultiProcessIterator(
              self.dataset,
              batched_indices,
              self.n_workers,
              prefetch=self.prefetch,
              worker_type=self.worker_type,
              timeout=self.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 3 for calling the DataLoader obj's underlying member method code with example usage: obj.__iter__() and returns: mainthread_data_iterator, MultiProcessIterator