'Return \'batchsize\' data points from the cache.'

def Get(self, batchsize, get_last_piece=False):

    skip = False
    if (self._pos == self.datasize):
        self._pos = 0
    if (self._pos == 0):
        if (self.empty or (self._maxpos < self.parent._maxpos)):
            if get_last_piece:
                self.LoadData(1)
            else:
                self.LoadData(batchsize)
            self.empty = False
        if self.randomize:
            self.ShuffleData()
    start = self._pos
    end = (self._pos + batchsize)
    if (end > self.datasize):
        end = self.datasize
        skip = (not get_last_piece)
    self._pos = end
    if skip:
        return self.Get(batchsize, get_last_piece=get_last_piece)
    else:
        for (i, d) in enumerate(self.data):
            centers = self.valid_indices[i].slice(start, end)
            self.ExtractWindows(d, centers, i)
        return self.batches
