class_docstr: Same as DataLoader except it uses torch-based shuffling buffers which enable batched buffering
  (significantly faster for small data).
docstr: Initializes a data loader object.
  
  Number of epochs is defined by the configuration of the reader argument.
  
  An optional shuffling queue is created if shuffling_queue_capacity is greater than 0. No samples will be
  returned to a user by the ``BatchedDataLoader`` until the queue is full. After that, batches of `batch_size`
  will be created by uniformly sampling the shuffling queue. Once no more samples are available from the data
  reader, the shuffling queue is allowed to be consumed till no further samples are available.
  
  Note that the last returned batch could have less then ``batch_size`` samples.
  
  NOTE: if you are using ``make_batch_reader``, this shuffling queue will be randomizing the order of the
  entire batches and not changing the order of elements within a batch. This is likely not what you intend to do.
  
  This class does not support special types that are not supported in PyTorch (decimal/string).
  
  :param reader: petastorm Reader instance
  :param batch_size: the number of items to return per batch; factored into the len() of this reader
  :param transform_fn: an optional callable to convert batches from the reader to PyTorch tensors
  :param shuffling_queue_capacity: Queue capacity is passed to the underlying :class:`tf.RandomShuffleQueue`
    instance. If set to 0, no shuffling will be done.
code: def __init__(
      self,
      reader,
      batch_size=1,
      transform_fn=None,
      shuffling_queue_capacity=0,
  ):
      """
      Initializes a data loader object.
  
      Number of epochs is defined by the configuration of the reader argument.
  
      An optional shuffling queue is created if shuffling_queue_capacity is greater than 0. No samples will be
      returned to a user by the ``BatchedDataLoader`` until the queue is full. After that, batches of `batch_size`
      will be created by uniformly sampling the shuffling queue. Once no more samples are available from the data
      reader, the shuffling queue is allowed to be consumed till no further samples are available.
  
      Note that the last returned batch could have less then ``batch_size`` samples.
  
      NOTE: if you are using ``make_batch_reader``, this shuffling queue will be randomizing the order of the
      entire batches and not changing the order of elements within a batch. This is likely not what you intend to do.
  
      This class does not support special types that are not supported in PyTorch (decimal/string).
  
      :param reader: petastorm Reader instance
      :param batch_size: the number of items to return per batch; factored into the len() of this reader
      :param transform_fn: an optional callable to convert batches from the reader to PyTorch tensors
      :param shuffling_queue_capacity: Queue capacity is passed to the underlying :class:`tf.RandomShuffleQueue`
        instance. If set to 0, no shuffling will be done.
      """
      super(BatchedDataLoader, self).__init__()
      self.reader = reader
      self.batch_size = batch_size
      self.transform_fn = transform_fn or torch.as_tensor
  
      # _batch_acc accumulates samples for a single batch.
      self._batch_acc = []
      self.shuffling_queue_capacity = shuffling_queue_capacity
      self._in_iter = None
  
imports: import collections.abc
  import decimal
  import re
  import logging
  import numpy
  from six import PY2
  from torch.utils.data.dataloader import default_collate
  import torch
  from packaging import version
  from petastorm.reader_impl.shuffling_buffer import RandomShufflingBuffer, NoopShufflingBuffer
  from petastorm.reader_impl.pytorch_shuffling_buffer import BatchedRandomShufflingBuffer, BatchedNoopShufflingBuffer
label_desc: Use image node_id 1 to create a new BatchedDataLoader object from inherited base classes: LoaderBase with example: obj = BatchedDataLoader(reader, batch_size, transform_fn, shuffling_queue_capacity)