<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def confusion_matrix(links_true, links_pred, total=None):
 """Compute the confusion matrix. The confusion matrix is of the following form: | | Predicted Positives | Predicted Negatives | +======================+=======================+======================+ | **True Positives** | True Positives (TP) | False Negatives (FN) | | **True Negatives** | False Positives (FP) | True Negatives (TN) | The confusion matrix is an informative way to analyse a prediction. The matrix can used to compute measures like precision and recall. The count of true prositives is [0,0], false negatives is [0,1], true negatives is [1,1] and false positives is [1,0]. Parameters links_true: pandas.MultiIndex, pandas.DataFrame, pandas.Series The true (or actual) links. links_pred: pandas.MultiIndex, pandas.DataFrame, pandas.Series The predicted links. total: int, pandas.MultiIndex The count of all record pairs (both links and non-links). When the argument is a pandas.MultiIndex, the length of the index is used. If the total is None, the number of True Negatives is not computed. Default None. Returns ------- numpy.array The confusion matrix with TP, TN, FN, FP values. Note ---- The number of True Negatives is computed based on the total argument. This argument is the number of record pairs of the entire matrix. """


    links_true = _get_multiindex(links_true)
    links_pred = _get_multiindex(links_pred)

    tp = true_positives(links_true, links_pred)
    fp = false_positives(links_true, links_pred)
    fn = false_negatives(links_true, links_pred)

    if total is None:
        tn = numpy.nan
    else:
        tn = true_negatives(links_true, links_pred, total)

    return numpy.array([[tp, fn], [fp, tn]])