def calculate_diff_metrics(util1, util2):
    """Calculate relative difference between two utilities"""
    util_diff = {}
    for metric_k1, metric_v1 in util1.items():
        if metric_k1 not in util2:
            continue
        util_diff[metric_k1] = {}
        for avg_k1, avg_v1 in metric_v1.items():
            if avg_k1 not in util2[metric_k1]:
                continue
            diff = abs(avg_v1 - util2[metric_k1][avg_k1]) / max(1e-9, avg_v1)
            util_diff[metric_k1][avg_k1] = diff
    return util_diff