class_docstr: Dataloader for loading batch data
  
  Example:
      .. code-block:: python
          from pgl.utils.data import Dataset
          from pgl.utils.data.dataloader import Dataloader
  
          class MyDataset(Dataset):
              def __init__(self):
                  self.data = list(range(0, 40))
  
              def __getitem__(self, idx):
                  return self.data[idx]
  
              def __len__(self):
                  return len(self.data)
  
          def collate_fn(batch_examples):
              feed_dict = {}
              feed_dict['data'] = batch_examples
              return feed_dict
  
          dataset = MyDataset()
          loader = Dataloader(dataset, 
                              batch_size=3,
                              drop_last=False,
                              shuffle=True,
                              num_workers=4,
                              collate_fn=collate_fn)
  
          for batch_data in loader:
              print(batch_data)
class_docstr_tok: ["Dataloader","for","loading","batch","data","Example",":","..","code-block",":",":","python","from","pgl.utils.data","import","Dataset","from","pgl.utils.data.dataloader","import","Dataloader","class","MyDataset","(","Dataset",")",":","def","__init__","(","self",")",":","self.data","=","list","(","range","(","0",",","40",")",")","def","__getitem__","(","self",",","idx",")",":","return","self.data","[","idx","]","def","__len__","(","self",")",":","return","len","(","self.data",")","def","collate_fn","(","batch_examples",")",":","feed_dict","=","{","}","feed_dict","[","'data","'","]","=","batch_examples","return","feed_dict","dataset","=","MyDataset","(",")","loader","=","Dataloader","(","dataset",",","batch_size=3",",","drop_last=False",",","shuffle=True",",","num_workers=4",",","collate_fn=collate_fn",")","for","batch_data","in","loader",":","print","(","batch_data",")"]
code: def __init__(
      self,
      dataset,
      batch_size=1,
      drop_last=False,
      shuffle=False,
      num_workers=1,
      collate_fn=None,
      buf_size=1000,
      stream_shuffle_size=0,
  ):
      self.dataset = dataset
      self.batch_size = batch_size
      self.shuffle = shuffle
      self.num_workers = num_workers
      self.collate_fn = collate_fn
      self.buf_size = buf_size
      self.drop_last = drop_last
      self.stream_shuffle_size = stream_shuffle_size
  
      if self.shuffle and isinstance(self.dataset, StreamDataset):
          warn_msg = (
              "The argument [shuffle] should not be True with StreamDataset. "
              "It will be ignored. "
              "You might want to set [stream_shuffle_size] with StreamDataset."
          )
          warnings.warn(warn_msg)
  
      if (
          self.stream_shuffle_size > 0
          and self.batch_size >= stream_shuffle_size
      ):
          raise ValueError(
              "stream_shuffle_size must be larger than batch_size,"
              "but got [stream_shuffle_size=%s] smaller than [batch_size=%s]"
              % (self.stream_shuffle_size, self.batch_size)
          )
  
      if self.stream_shuffle_size > 0 and isinstance(
          self.dataset, Dataset
      ):
          warn_msg = (
              "[stream_shuffle_size] should not be set with Dataset. "
              "It will be ignored. "
              "You might want to set [shuffle] with Dataset."
          )
          warnings.warn(warn_msg)
  
      if self.num_workers < 1:
          raise ValueError(
              "num_workers(default: 1) should be larger than 0, "
              "but got [num_workers=%s] < 1." % self.num_workers
          )
  
      if isinstance(self.dataset, StreamDataset):  # for stream data
          # generating a iterable sequence for produce batch data without repetition
          self.sampler = StreamSampler(
              self.dataset,
              batch_size=self.batch_size,
              drop_last=self.drop_last,
          )
      else:
          self.sampler = Sampler(
              self.dataset,
              batch_size=self.batch_size,
              drop_last=self.drop_last,
              shuffle=self.shuffle,
          )
  
imports: import warnings
  import time
  import numpy
  from collections import namedtuple
  import paddle
  import paddle.fluid
  import paddle.fluid.layers
  from pgl.utils import mp_reader
  from pgl.utils.data.dataset import Dataset, StreamDataset
  from pgl.utils.data.sampler import Sampler, StreamSampler
label_desc: Use image node_id 1 to create a new Dataloader object from inherited base classes: object with example: obj = Dataloader(dataset, batch_size, drop_last, shuffle, num_workers, collate_fn, buf_size, stream_shuffle_size)