def next_sample(self):
    'Helper function for reading in next sample.'
    if (self._allow_read is False):
        raise StopIteration
    if (self.seq is not None):
        if (self.cur < self.num_image):
            idx = self.seq[self.cur]
        else:
            if (self.last_batch_handle != 'discard'):
                self.cur = 0
            raise StopIteration
        self.cur += 1
        if (self.imgrec is not None):
            s = self.imgrec.read_idx(idx)
            (header, img) = recordio.unpack(s)
            if (self.imglist is None):
                return (header.label, img)
            else:
                return (self.imglist[idx][0], img)
        else:
            (label, fname) = self.imglist[idx]
            return (label, self.read_image(fname))
    else:
        s = self.imgrec.read()
        if (s is None):
            if (self.last_batch_handle != 'discard'):
                self.imgrec.reset()
            raise StopIteration
        (header, img) = recordio.unpack(s)
        return (header.label, img)
Helper function for reading in next sample.
def next_sample(self):
    
    if (self._allow_read is False):
        raise StopIteration
    if (self.seq is not None):
        if (self.cur < self.num_image):
            idx = self.seq[self.cur]
        else:
            if (self.last_batch_handle != 'discard'):
                self.cur = 0
            raise StopIteration
        self.cur += 1
        if (self.imgrec is not None):
            s = self.imgrec.read_idx(idx)
            (header, img) = recordio.unpack(s)
            if (self.imglist is None):
                return (header.label, img)
            else:
                return (self.imglist[idx][0], img)
        else:
            (label, fname) = self.imglist[idx]
            return (label, self.read_image(fname))
    else:
        s = self.imgrec.read()
        if (s is None):
            if (self.last_batch_handle != 'discard'):
                self.imgrec.reset()
            raise StopIteration
        (header, img) = recordio.unpack(s)
        return (header.label, img)