<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _rescale_to_unit_diagonals(mat):
 """Rescale matrix to have unit diagonals. Note: Call only after diagonal dominance is ensured. """

    d = np.sqrt(np.diag(mat))
    mat /= d
    mat /= d[:, np.newaxis]
    return mat