code: def _save_eval_stats(opt, report):
      if not is_primary_worker:
          return
      report_fname = opt["report_filename"]
      if report_fname == "":
          return
      if report_fname.startswith("."):
          report_fname = opt["model_file"] + report_fname
  
      json_serializable_report = report
      for k, v in report.items():
          if isinstance(v, Metric):
              v = v.value()
          json_serializable_report[k] = v
  
      # Save report
      with PathManager.open(report_fname, "w") as f:
          logging.info(f"Saving model report to {report_fname}")
          json.dump(
              {"opt": opt, "report": json_serializable_report},
              f,
              indent=4,
          )
          f.write("\n")
  
imports: from parlai.core.params import ParlaiParser, print_announcements
  from parlai.core.agents import create_agent
  from parlai.core.logs import TensorboardLogger
  from parlai.core.metrics import aggregate_named_reports, aggregate_unnamed_reports, Metric
  from parlai.core.opt import Opt
  from parlai.core.worlds import create_task
  from parlai.utils.misc import TimeLogger, nice_report
  from parlai.utils.world_logging import WorldLogger
  from parlai.core.script import ParlaiScript, register_script
  from parlai.utils.io import PathManager
  import parlai.utils.logging
  import json
  import os
  import random
  from parlai.utils.distributed import is_primary_worker, all_gather_list, is_distributed, get_rank
label_desc: Use image node_id 2 for calling a global function with example usage: _save_eval_stats(opt, report) without return types