'Args:
ds (DataFlow): input DataFlow.
buffer_size (int): size of the buffer.
nr_reuse (int): reuse each datapoints several times to improve
speed, but may hurt your model.
shuffle_interval (int): shuffle the buffer after this many
datapoints went through it. Frequent shuffle on large buffer
may affect speed, but infrequent shuffle may affect
randomness. Defaults to buffer_size / 3'

def __init__(self, ds, buffer_size, nr_reuse=1, shuffle_interval=None):

    ProxyDataFlow.__init__(self, ds)
    self.q = deque(maxlen=buffer_size)
    if (shuffle_interval is None):
        shuffle_interval = int((buffer_size // 3))
    self.shuffle_interval = shuffle_interval
    self.nr_reuse = nr_reuse
    self._guard = DataFlowReentrantGuard()
