<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def psq2(d1, d2):
 """Compute the PSQ2 measure. Args: d1 (np.ndarray):
 The first distribution. d2 (np.ndarray):
 The second distribution. """

    d1, d2 = flatten(d1), flatten(d2)

    def f(p):
        return sum((p ** 2) * np.nan_to_num(np.log(p * len(p))))

    return abs(f(d1) - f(d2))