'Fill bucketed batches into the bucket_input_queue.'

def _FillBucketInputQueue(self):

    while True:
        inputs = []
        for _ in xrange((self._hps.batch_size * BUCKET_CACHE_BATCH)):
            inputs.append(self._input_queue.get())
        if self._bucketing:
            inputs = sorted(inputs, key=(lambda inp: inp.enc_len))
        batches = []
        for i in xrange(0, len(inputs), self._hps.batch_size):
            batches.append(inputs[i:(i + self._hps.batch_size)])
        shuffle(batches)
        for b in batches:
            self._bucket_input_queue.put(b)
