def __init__(self, data_source, batch_size=1):
    '\n        Samples batches assuming they are in order of size to batch similarly sized samples together.\n        '
    super(BucketingSampler, self).__init__(data_source)
    self.data_source = data_source
    ids = list(range(0, len(data_source)))
    self.bins = [ids[i:(i + batch_size)] for i in range(0, len(ids), batch_size)]
Samples batches assuming they are in order of size to batch similarly sized samples together.
def __init__(self, data_source, batch_size=1):
    '\n        \n        '
    super(BucketingSampler, self).__init__(data_source)
    self.data_source = data_source
    ids = list(range(0, len(data_source)))
    self.bins = [ids[i:(i + batch_size)] for i in range(0, len(ids), batch_size)]