from typing import Dict


def get_joint_acc(results: Dict[str, dict]) -> float:
    """Calculate joint accuracy.

    Args:
        results: from Trainer.format_results method

    Returns:
        turn joint accuracy
    """
    joint_acc = []
    for _, dial in results.items():
        for _, turn in dial.items():
            if turn["preds"] == turn["labels"]:
                joint_acc.append(1)
            else:
                joint_acc.append(0)

    joint_acc = sum(joint_acc) / len(joint_acc)
    return joint_acc