class_docstr: DataLoader
  
  Args:
      data_source (`Uniton[Iterable, Callable]`)
          Read data from a data_source (can be an iterable or a callable)
  
      parser (`Callable`):
          Parse the read data through the parser function to get the input that the pipeline can process.
  
      batch_size (`int`)
          If batch_size is specified, batch the read data into batches of size batch_size, otherwise yield single data directly
  
  Examples:
      >>> from towhee import DataLoader, pipe, ops
      >>> p = pipe.input('num').map('num', 'ret', lambda x: x + 1).output('ret')
      >>> for data in DataLoader([{'num': 1}, {'num': 2}, {'num': 3}], parser=lambda x: x['num']):
      >>>     print(p(data).to_list(kv_format=True))
      [{'ret': 2}]
      [{'ret': 3}]
      [{'ret': 4}]
class_docstr_tok: ["DataLoader","Args",":","data_source","(","`","Uniton","[","Iterable",",","Callable","]","`",")","Read","data","from","a","data_source","(","can","be","an","iterable","or","a","callable",")","parser","(","`","Callable","`",")",":","Parse","the","read","data","through","the","parser","function","to","get","the","input","that","the","pipeline","can","process",".","batch_size","(","`","int","`",")","If","batch_size","is","specified",",","batch","the","read","data","into","batches","of","size","batch_size",",","otherwise","yield","single","data","directly","Examples",":",">",">",">","from","towhee","import","DataLoader",",","pipe",",","ops",">",">",">","p","=","pipe.input","(","'num","'",")",".map","(","'num","'",",","'ret","'",",","lambda","x",":","x","+","1",")",".output","(","'ret","'",")",">",">",">","for","data","in","DataLoader","(","[","{","'num","'",":","1","}",",","{","'num","'",":","2","}",",","{","'num","'",":","3","}","]",",","parser=lambda","x",":","x","[","'num","'","]",")",":",">",">",">","print","(","p","(","data",")",".to_list","(","kv_format=True",")",")","[","{","'ret","'",":","2","}","]","[","{","'ret","'",":","3","}","]","[","{","'ret","'",":","4","}","]"]
code: def __init__(
      self,
      data_source: Union[Iterable, Callable],
      parser: Callable = None,
      batch_size: int = None,
  ):
      self._ds = data_source
      self._parser = parser if parser is not None else lambda x: x
      self._batch_size = batch_size
  
imports: from typing import Callable, Iterable, Union
label_desc: Use image node_id 1 to create a new DataLoader object  with example: obj = DataLoader(data_source, parser, batch_size)