def __data_generation(self, list_keys_temp):
    max_num_blocks = 0
    max_num_frames = 0
    for (i, key) in enumerate(list_keys_temp):
        mat = self.h5fd[(key + '/data')][()]
        mat = mat_utils.pad_mat(mat, self.mod)
        [ex_blocks, ex_frames] = multi_utils.expected_num_blocks(mat, self.procs, self.extras1, self.extras2, self.num_extras1)
        if (ex_blocks > max_num_blocks):
            max_num_blocks = ex_blocks
        if (ex_frames > max_num_frames):
            max_num_frames = ex_frames
    input_mat = np.zeros((len(list_keys_temp), max_num_blocks, (self.procs + max(self.extras1, self.extras2)), self.feat_dim))
    input_mask = np.zeros((len(list_keys_temp), max_num_blocks, (self.procs + max(self.extras1, self.extras2)), 1))
    if (self.mode == 'train'):
        numer_labels = np.zeros((len(list_keys_temp), max_num_blocks, (self.procs + max(self.extras1, self.extras2)), (self.n_labels + 1)))
        numer_lmscores = np.zros((len(list_keys_temp), 1))
        denom_labels = np.zeros((len(list_keys_temp), self.nbest, max_num_blocks, (self.procs + max(self.extras1, self.extras2)), (self.n_labels + 1)))
        denom_lmlscores = np.zeros((len(list_keys_temp), self.nbest, 1))
    for (i, key) in enumerate(list_keys_temp):
        mat = self.h5fd[(key + '/data')][()]
        [ex_blocks, ex_frames] = multi_utils.expected_num_blocks(mat, self.procs, self.extras1, self.extras2, self.num_extras1)
        (blocked_mat, mask, _) = multi_utils.split_utt(mat, self.procs, self.extras1, self.extras2, self.num_extras1, ex_blocks, self.feat_dim, max_num_blocks)
        input_mat[i, :, :, :] = np.expand_dims(blocked_mat, axis=0)
        input_mask[i, :, :, :] = np.expand_dims(mask, axis=0)
        if (self.mode == 'train'):
            numer = self.h5fd[(key + '/1best')][()]
            numer_labels = multi_utils.str2dict(numer)
            numer_lmscores[(i, 0)] = self.h5fd[(key + '/1best_scores')][()]
            denom = self.h5fd[(key + '/nbest')][()]
            denom_labels = multi_utils.str2nbest(denom)
            denom_lmscores[i, :, 0] = self.h5fd[(key + '/nbest_scores')][()]
            number_blocked_labels = multi_utils.split_post_label(numer_labels, self.procs, self.extras1, self.extras2, self.num_extras1, ex_blocks, (self.n_labels + 1), max_num_blocks)
            numer_labels[i, :, :, :] = np.expand_dims(numer_blocked_labels, axis=0)
            denom_blocked_labels = muti_utils.split_nbest_label(denom_labels, self.procs, self.extra1, self.extra2, self.num_extras1, ex_blocks, (self.n_labels + 1), max_num_blocks)
            denom_labels[i, :, :, :, :] = np.expand_dims(denom_blocked_labels, axis=0)
    input_mat = input_mat.transpose((1, 0, 2, 3))
    input_mask = input_mask.transpose((1, 0, 2, 3))
    if (self.mode == 'train'):
        number_labels = numer_labels.transpose((1, 0, 2, 3))
        denom_labels = denom_labels.transpose((2, 1, 0, 3, 4))
    if (self.mode == 'train'):
        return (input_mat, input_mask, [numer_labels, numer_lmscores, denom_labels, denom_lmscores])
    else:
        return (input_mat, input_mask)
def __data_generation(self, list_keys_temp):
    max_num_blocks = 0
    max_num_frames = 0
    for (i, key) in enumerate(list_keys_temp):
        mat = self.h5fd[(key + '/data')][()]
        mat = mat_utils.pad_mat(mat, self.mod)
        [ex_blocks, ex_frames] = multi_utils.expected_num_blocks(mat, self.procs, self.extras1, self.extras2, self.num_extras1)
        if (ex_blocks > max_num_blocks):
            max_num_blocks = ex_blocks
        if (ex_frames > max_num_frames):
            max_num_frames = ex_frames
    input_mat = np.zeros((len(list_keys_temp), max_num_blocks, (self.procs + max(self.extras1, self.extras2)), self.feat_dim))
    input_mask = np.zeros((len(list_keys_temp), max_num_blocks, (self.procs + max(self.extras1, self.extras2)), 1))
    if (self.mode == 'train'):
        numer_labels = np.zeros((len(list_keys_temp), max_num_blocks, (self.procs + max(self.extras1, self.extras2)), (self.n_labels + 1)))
        numer_lmscores = np.zros((len(list_keys_temp), 1))
        denom_labels = np.zeros((len(list_keys_temp), self.nbest, max_num_blocks, (self.procs + max(self.extras1, self.extras2)), (self.n_labels + 1)))
        denom_lmlscores = np.zeros((len(list_keys_temp), self.nbest, 1))
    for (i, key) in enumerate(list_keys_temp):
        mat = self.h5fd[(key + '/data')][()]
        [ex_blocks, ex_frames] = multi_utils.expected_num_blocks(mat, self.procs, self.extras1, self.extras2, self.num_extras1)
        (blocked_mat, mask, _) = multi_utils.split_utt(mat, self.procs, self.extras1, self.extras2, self.num_extras1, ex_blocks, self.feat_dim, max_num_blocks)
        input_mat[i, :, :, :] = np.expand_dims(blocked_mat, axis=0)
        input_mask[i, :, :, :] = np.expand_dims(mask, axis=0)
        if (self.mode == 'train'):
            numer = self.h5fd[(key + '/1best')][()]
            numer_labels = multi_utils.str2dict(numer)
            numer_lmscores[(i, 0)] = self.h5fd[(key + '/1best_scores')][()]
            denom = self.h5fd[(key + '/nbest')][()]
            denom_labels = multi_utils.str2nbest(denom)
            denom_lmscores[i, :, 0] = self.h5fd[(key + '/nbest_scores')][()]
            number_blocked_labels = multi_utils.split_post_label(numer_labels, self.procs, self.extras1, self.extras2, self.num_extras1, ex_blocks, (self.n_labels + 1), max_num_blocks)
            numer_labels[i, :, :, :] = np.expand_dims(numer_blocked_labels, axis=0)
            denom_blocked_labels = muti_utils.split_nbest_label(denom_labels, self.procs, self.extra1, self.extra2, self.num_extras1, ex_blocks, (self.n_labels + 1), max_num_blocks)
            denom_labels[i, :, :, :, :] = np.expand_dims(denom_blocked_labels, axis=0)
    input_mat = input_mat.transpose((1, 0, 2, 3))
    input_mask = input_mask.transpose((1, 0, 2, 3))
    if (self.mode == 'train'):
        number_labels = numer_labels.transpose((1, 0, 2, 3))
        denom_labels = denom_labels.transpose((2, 1, 0, 3, 4))
    if (self.mode == 'train'):
        return (input_mat, input_mask, [numer_labels, numer_lmscores, denom_labels, denom_lmscores])
    else:
        return (input_mat, input_mask)