<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mp2q(p, q):
 """Compute the MP2Q measure. Args: p (np.ndarray):
 The unpartitioned repertoire q (np.ndarray):
 The partitioned repertoire """

    p, q = flatten(p), flatten(q)
    entropy_dist = 1 / len(p)
    return sum(entropy_dist * np.nan_to_num((p ** 2) / q * np.log(p / q)))