docstr: Implementing accuracy computation for AOKVQA, see
  https://github.com/allenai/aokvqa/blob/main/evaluation/eval_predictions.py#L45 for details.
docstr_tok: ["Implementing","accuracy","computation","for","AOKVQA",",","see","https",":","\/\/github.com\/allenai\/aokvqa\/blob\/main\/evaluation\/eval_predictions.py","#","L45","for","details","."]
code: def _report_metrics(self, result_file, split):
      """
      Implementing accuracy computation for AOKVQA, see
      https://github.com/allenai/aokvqa/blob/main/evaluation/eval_predictions.py#L45 for details.
      """
      # TODO add evaluation for multi-choice
  
      results = json.load(open(result_file, "r"))
      acc = []
  
      for res in results:
          if res["gt_ans"] is None:
              # prepare test results for leaderboard evaluation
              self._save_result_leaderboard(results)
              return
  
          pred = res["pred_ans"]
          gt_ans = res["gt_ans"]
  
          num_match = sum([pred == gt for gt in gt_ans])
          vqa_acc = min(1.0, num_match / 3.0)
  
          acc.append(vqa_acc)
  
      accuracy = sum(acc) / len(acc) * 100
      metrics = {"agg_metrics": accuracy, "acc": accuracy}
  
      with open(
          os.path.join(registry.get_path("output_dir"), "evaluate.txt"),
          "a",
      ) as f:
          f.write(json.dumps(metrics) + "\n")
  
      logging.info(metrics)
  
      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 2 for calling the AOKVQATask obj's underlying member method code with example usage: obj._report_metrics(result_file, split) and returns: metrics