'Reads data from disk.
Args:
batchsize: Number of data points to read.
Returns:
A list of numpy arrays each with batchsize rows. Each element of the list
is one data modality.'

def Get(self, batchsize):

    data_list = []
    for i in range(self.num_data):
        key = self.keys[i]
        numdims = self.numdim_list[i]
        filename_list = self.filenames[i]
        num_files = self._num_file_list[i]
        current_file = ((self.last_read_file[i] + 1) % num_files)
        sparse = (os.path.splitext(filename_list[current_file])[1] == '.npz')
        if sparse:
            data = None
        else:
            if (self.data[i] is None):
                self.data[i] = np.zeros((batchsize, numdims), dtype='float32')
            data = self.data[i]
        datasize = 0
        if (self.left_overs[i] is not None):
            left_over_size = self.left_overs[i].shape[0]
            if (left_over_size > batchsize):
                if sparse:
                    data = self.left_overs[i][:batchsize]
                else:
                    data[:batchsize] = self.left_overs[i][:batchsize]
                self.left_overs[i] = self.left_overs[i][batchsize:]
                datasize = batchsize
            else:
                if sparse:
                    data = self.left_overs[i]
                else:
                    data[:left_over_size] = self.left_overs[i]
                self.left_overs[i] = None
                datasize = left_over_size
        while (datasize < batchsize):
            if (self.last_read_file[i] != current_file):
                this_chunk = self.ReadDiskData(filename_list[current_file], key)
                self.last_read_chunk[i] = this_chunk
                self.last_read_file[i] = current_file
            else:
                this_chunk = self.last_read_chunk[i]
            this_chunk_size = this_chunk.shape[0]
            if ((datasize + this_chunk_size) > batchsize):
                self.left_overs[i] = this_chunk[(batchsize - datasize):]
                if sparse:
                    data = self.AddSparseData(data, this_chunk[:(batchsize - datasize)])
                else:
                    data[datasize:batchsize] = this_chunk[:(batchsize - datasize)]
                datasize = batchsize
            else:
                self.left_overs[i] = None
                if sparse:
                    data = self.AddSparseData(data, this_chunk)
                else:
                    data[datasize:(datasize + this_chunk_size)] = this_chunk
                datasize += this_chunk_size
            current_file = ((current_file + 1) % num_files)
        data_list.append(data)
    return data_list
