def evaluate_method(gtFilePath, submFilePath, evaluationParams):
    """
    Method evaluate_method: evaluate method and returns the results
        Results. Dictionary with the following values:
        - method (required)  Global method metrics. Ex: { 'Precision':0.8,'Recall':0.9 }
        - samples (optional) Per sample metrics. Ex: {'sample1' : { 'Precision':0.8,'Recall':0.9 } , 'sample2' : { 'Precision':0.8,'Recall':0.9 }
    """

    show_scores_per_answer_type = evaluationParams.answer_types

    gtJson = json.load(open(gtFilePath, 'rb'))
    submJson = json.load(open(submFilePath, 'rb'))

    res_id_to_index = {int(r['questionId']): ix for ix, r in enumerate(submJson)}

    perSampleMetrics = {}

    totalScore = 0
    row = 0

    if show_scores_per_answer_type:
        answerTypeTotalScore = {x: 0 for x in answer_types.keys()}
        answerTypeNumQuestions = {x: 0 for x in answer_types.keys()}

        evidenceTypeTotalScore = {x: 0 for x in evidence_types.keys()}
        evidenceTypeNumQuestions = {x: 0 for x in evidence_types.keys()}

        reasoningTypeTotalScore = {x: 0 for x in reasoning_requirements.keys()}
        reasoningTypeNumQuestions = {x: 0 for x in reasoning_requirements.keys()}

    for gtObject in gtJson['data']:

        q_id = int(gtObject['questionId'])
        res_ix = res_id_to_index[q_id]
        detObject = submJson[res_ix]

        if q_id in question_ids_to_exclude:
            question_result = 0
            info = 'Question EXCLUDED from the result'

        else:
            info = ''
            values = []
            for answer in gtObject['answers']:
                # preprocess both the answers - gt and prediction
                gt_answer = ' '.join(answer.strip().lower().split())
                det_answer = ' '.join(detObject['answer'].strip().lower().split())

                # dist = levenshtein_distance(answer.lower(), detObject['answer'].lower())
                dist = levenshtein_distance(gt_answer, det_answer)
                length = max(len(answer.upper()), len(detObject['answer'].upper()))
                values.append(0.0 if length == 0 else float(dist) / float(length))

            question_result = 1 - min(values)

            if (question_result < evaluationParams.anls_threshold):
                question_result = 0

            totalScore += question_result

            if show_scores_per_answer_type:
                for q_type in gtObject['answer_type']:
                    answerTypeTotalScore[q_type] += question_result
                    answerTypeNumQuestions[q_type] += 1

                for q_type in gtObject['evidence']:
                    evidenceTypeTotalScore[q_type] += question_result
                    evidenceTypeNumQuestions[q_type] += 1

                for q_type in gtObject['operation/reasoning']:
                    reasoningTypeTotalScore[q_type] += question_result
                    reasoningTypeNumQuestions[q_type] += 1

        perSampleMetrics[str(gtObject['questionId'])] = {
            'score': question_result,
            'question': gtObject['question'],
            'gt': gtObject['answers'],
            'det': detObject['answer'],
            'info': info
        }
        row = row + 1

    methodMetrics = {
        'score': 0 if len(gtJson['data']) == 0 else totalScore / (len(gtJson['data']) - len(question_ids_to_exclude))
    }

    answer_types_scores = {}
    evidence_types_scores = {}
    operation_types_scores = {}

    if show_scores_per_answer_type:
        for a_type, ref in answer_types.items():
            answer_types_scores[ref] = 0 if len(gtJson['data']) == 0 else answerTypeTotalScore[a_type] / (
            answerTypeNumQuestions[a_type])

        for e_type, ref in evidence_types.items():
            evidence_types_scores[ref] = 0 if len(gtJson['data']) == 0 else evidenceTypeTotalScore[e_type] / (
            evidenceTypeNumQuestions[e_type])

        for r_type, ref in reasoning_requirements.items():
            operation_types_scores[ref] = 0 if len(gtJson['data']) == 0 else reasoningTypeTotalScore[r_type] / (
            reasoningTypeNumQuestions[r_type])

    resDict = {
        'result': methodMetrics,
        'scores_by_types': {'answer_types': answer_types_scores, 'evidence_types': evidence_types_scores,
                            'operation_types': operation_types_scores},
        'per_sample_result': perSampleMetrics
    }

    return resDict

    Method evaluate_method: evaluate method and returns the results
        Results. Dictionary with the following values:
        - method (required)  Global method metrics. Ex: { 'Precision':0.8,'Recall':0.9 }
        - samples (optional) Per sample metrics. Ex: {'sample1' : { 'Precision':0.8,'Recall':0.9 } , 'sample2' : { 'Precision':0.8,'Recall':0.9 }
    
internvl_chat/eval/mpdocvqa/infographicsvqa_eval.py