docstr: Use official VQA evaluation script to report metrics.
docstr_tok: ["Use","official","VQA","evaluation","script","to","report","metrics","."]
code: def _report_metrics(self, result_file, split):
      """
      Use official VQA evaluation script to report metrics.
      """
      metrics = {}
  
      if split in self.ques_files and split in self.anno_files:
          vqa = VQA(self.anno_files[split], self.ques_files[split])
          vqa_result = vqa.loadRes(
              resFile=result_file, quesFile=self.ques_files[split]
          )
          # create vqaEval object by taking vqa and vqaRes
          # n is precision of accuracy (number of places after decimal), default is 2
          vqa_scorer = VQAEval(vqa, vqa_result, n=2)
          logging.info("Start VQA evaluation.")
          vqa_scorer.evaluate()
  
          # print accuracies
          overall_acc = vqa_scorer.accuracy["overall"]
          metrics["agg_metrics"] = overall_acc
  
          logging.info("Overall Accuracy is: %.02f\n" % overall_acc)
          logging.info("Per Answer Type Accuracy is the following:")
  
          for ans_type in vqa_scorer.accuracy["perAnswerType"]:
              logging.info(
                  "%s : %.02f"
                  % (
                      ans_type,
                      vqa_scorer.accuracy["perAnswerType"][ans_type],
                  )
              )
              metrics[ans_type] = vqa_scorer.accuracy["perAnswerType"][
                  ans_type
              ]
  
          with open(
              os.path.join(
                  registry.get_path("output_dir"), "evaluate.txt"
              ),
              "a",
          ) as f:
              f.write(json.dumps(metrics) + "\n")
      return metrics
  
imports: import logging
  import json
  import os
  import torch
  from tqdm import tqdm
  from lavis.common.utils import is_convertible_to_int
  import lavis.common.dist_utils
  from lavis.common.registry import registry
  from lavis.common.vqa_tools.vqa import VQA
  from lavis.common.vqa_tools.vqa_eval import VQAEval
  from lavis.tasks.base_task import BaseTask
label_desc: Use image node_id 6 for calling the VQATask obj's underlying member method code with example usage: obj._report_metrics(result_file, split) and returns: metrics