def tf_pair_aggregate_accuracy(results):
    """
    Aggregate evaluation results for the tf pair task.
    Group by index, where the index format is like "pc-cpr_1_p" and "pc-cpr_1_n",
    taking the prefix (removing the last _p or _n) as the identifier for the same group.
    If all records in the group have predictions that match the answer ("T" or "F"), the group is considered correct,
    returning the ratio of correct groups to total groups.
    """
    groups = defaultdict(list)
    for item in results:
        idx = item.get("index", "")
        if "_" not in idx:
            continue
        base_id = "_".join(idx.split("_")[:-1])
        groups[base_id].append(item)
    total_groups = len(groups)
    correct_groups = 0
    for base_id, items in groups.items():
        # At least two records are required in the group
        if len(items) < 2:
            continue
        group_correct = True
        for item in items:
            gt = item.get("answer", "").strip().upper()
            pred = item.get("prediction", "").strip().upper()
            parsed, err = parse_tf_answer(pred)
            if parsed != gt:
                group_correct = False
                break
        if group_correct:
            correct_groups += 1
    return (correct_groups / total_groups) * 100 if total_groups > 0 else 0

    Aggregate evaluation results for the tf pair task.
    Group by index, where the index format is like "pc-cpr_1_p" and "pc-cpr_1_n",
    taking the prefix (removing the last _p or _n) as the identifier for the same group.
    If all records in the group have predictions that match the answer ("T" or "F"), the group is considered correct,
    returning the ratio of correct groups to total groups.
    
vlmeval/dataset/utils/vlm2bench.py