<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def matrix_params_from_table(table, transpose=False):
 """ Calculate TP,TN,FP,FN from confusion matrix. :param table: input matrix :type table : dict :param transpose : transpose flag :type transpose : bool :return: [classes_list,table,TP,TN,FP,FN] """

    classes = sorted(table.keys())
    map_dict = {k: 0 for k in classes}
    TP_dict = map_dict.copy()
    TN_dict = map_dict.copy()
    FP_dict = map_dict.copy()
    FN_dict = map_dict.copy()
    for i in classes:
        TP_dict[i] = table[i][i]
        sum_row = sum(list(table[i].values()))
        for j in classes:
            if j != i:
                FN_dict[i] += table[i][j]
                FP_dict[j] += table[i][j]
                TN_dict[j] += sum_row - table[i][j]
    if transpose:
        temp = FN_dict
        FN_dict = FP_dict
        FP_dict = temp
        table = transpose_func(classes, table)
    return [classes, table, TP_dict, TN_dict, FP_dict, FN_dict]