'Returns the next batch of data.'

def next(self):

    if (self.curr_idx == len(self.idx)):
        raise StopIteration
    (i, j) = self.idx[self.curr_idx]
    self.curr_idx += 1
    if (self.major_axis == 1):
        data = self.nddata[i][j:(j + self.batch_size)].T
        label = self.ndlabel[i][j:(j + self.batch_size)].T
    else:
        data = self.nddata[i][j:(j + self.batch_size)]
        label = self.ndlabel[i][j:(j + self.batch_size)]
    return DataBatch([data], [label], pad=0, bucket_key=self.buckets[i], provide_data=[DataDesc(name=self.data_name, shape=data.shape, layout=self.layout)], provide_label=[DataDesc(name=self.label_name, shape=label.shape, layout=self.layout)])
