def cnt_aggregate_metric(results):
    """
    Aggregate evaluation results for the CNT task.
    For each sample, parse the numbers in the prediction and compare them with the answer (which should be an integer),
    calculate the score based on the error, and return the average score of all samples.
    """
    total_count = 0
    total_norm_score = 0.0
    for item in results:
        try:
            gt = int(item.get("answer", None))
        except:
            gt = None
        if gt is None:
            continue
        total_count += 1
        model_ans_str = str(item.get("prediction", "")).strip()
        # Try to use the image_seq_len provided in the record; if not, default to 2
        image_seq_len = item.get("image_seq_len", 2)
        try:
            image_seq_len = int(image_seq_len)
        except:
            image_seq_len = 2

        parsed = parse_model_answer(model_ans_str)
        if parsed is None:
            norm_score = 0.0
        else:
            raw_diff = abs(parsed - gt)
            if raw_diff == 0:
                norm_score = 100.0
            else:
                max_error = max(gt - 1, image_seq_len - gt)
                if max_error <= 0:
                    max_error = 1
                relative_error = raw_diff / max_error
                weight = L_MAX / image_seq_len
                penalty = weight * (relative_error ** (1.0 / PENALTY_FACTOR))
                norm_score = 100 * (1 - penalty) if penalty < 1 else 0.0
        total_norm_score += norm_score
    return total_norm_score / total_count if total_count > 0 else 0

    Aggregate evaluation results for the CNT task.
    For each sample, parse the numbers in the prediction and compare them with the answer (which should be an integer),
    calculate the score based on the error, and return the average score of all samples.
    
vlmeval/dataset/utils/vlm2bench.py