<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def corr_flat_dir(a1, a2):
    '''
    Returns the correlation coefficient between two flattened adjacency
    matrices.  Similarity metric for weighted matrices.

    Parameters
    ----------
    A1 : NxN np.ndarray
        directed matrix 1
    A2 : NxN np.ndarray
        directed matrix 2

    Returns
    -------
    r : float
        Correlation coefficient describing edgewise similarity of a1 and a2
    '''
    n = len(a1)
    if len(a2) != n:
        raise BCTParamError("Cannot calculate flattened correlation on "
                            "matrices of different size")
    ix = np.logical_not(np.eye(n))
    return np.corrcoef(a1[ix].flat, a2[ix].flat)[0][1]