def find_all_best_thresh(
    main_eval, preds, exact_raw, f1_raw, na_probs, qid_to_has_ans, unanswerable_exists=False
):
    """
    Update raw evaluation scores by finding the best threshold to determine a question is
    impossible to answer.

    Args:
        main_eval (dict): Dictionary with raw evaluation scores without apply any threshold.
        preds (dict): Dictionary with qa_id as keys and predicted answers as values.
        exact_raw (dict): Dictionary with qa_id as keys and raw exact_match scores as values.
        f1_raw (dict): Dictionary with qa_id as keys and raw f1 scores as values.
        na_probs (dict): Dictionary with qa_id as keys and unanswerable probabilities as values.
        qid_to_has_ans (dict): Dictionary with qa_id as keys boolean values indicating if the
            question has answer as values.
        unanswerable_exists (bool, optional): Whether there is unanswerable questions in the data.
            Defaults to False.

    Returns:
        dict: Updated `main_eval` with scores after applying best threshold and best threshold
            for each score.
    """
    all_exact = find_best_thresh(preds, exact_raw, na_probs, qid_to_has_ans, unanswerable_exists)
    all_f1 = find_best_thresh(preds, f1_raw, na_probs, qid_to_has_ans, unanswerable_exists)
    main_eval["best_exact"] = all_exact[0]
    main_eval["best_exact_thresh"] = all_exact[1]
    main_eval["best_f1"] = all_f1[0]
    main_eval["best_f1_thresh"] = all_f1[1]

    if unanswerable_exists:
        main_eval["has_ans_exact"] = all_exact[2]
        main_eval["has_ans_f1"] = all_f1[2]

    Update raw evaluation scores by finding the best threshold to determine a question is
    impossible to answer.

    Args:
        main_eval (dict): Dictionary with raw evaluation scores without apply any threshold.
        preds (dict): Dictionary with qa_id as keys and predicted answers as values.
        exact_raw (dict): Dictionary with qa_id as keys and raw exact_match scores as values.
        f1_raw (dict): Dictionary with qa_id as keys and raw f1 scores as values.
        na_probs (dict): Dictionary with qa_id as keys and unanswerable probabilities as values.
        qid_to_has_ans (dict): Dictionary with qa_id as keys boolean values indicating if the
            question has answer as values.
        unanswerable_exists (bool, optional): Whether there is unanswerable questions in the data.
            Defaults to False.

    Returns:
        dict: Updated `main_eval` with scores after applying best threshold and best threshold
            for each score.
    
utils_nlp/eval/question_answering.py