code: def _eval_single_world(opt, agent, task):
      logging.info(
          f'Evaluating task {task} using datatype {opt.get("datatype")}.'
      )
      # set up world logger
      task_opt = opt.copy()  # copy opt since we're editing the task
      task_opt["task"] = task
      # add task suffix in case of multi-tasking
      if opt["world_logs"]:
          task_opt["world_logs"] = get_task_world_logs(
              task,
              task_opt["world_logs"],
              is_multitask=len(opt["task"].split(",")) > 1,
          )
  
      world_logger = (
          WorldLogger(task_opt) if task_opt["world_logs"] else None
      )
  
      world = create_task(task_opt, agent)  # create worlds for tasks
  
      # set up logging
      log_every_n_secs = opt.get("log_every_n_secs", -1)
      if log_every_n_secs <= 0:
          log_every_n_secs = float("inf")
      log_time = TimeLogger()
  
      # max number of examples to evaluate
      max_cnt = (
          opt["num_examples"]
          if opt["num_examples"] > 0
          else float("inf")
      )
      cnt = 0
      total_cnt = world.num_examples()
  
      if is_distributed():
          logging.warning(
              "Progress bar is approximate in distributed mode."
          )
  
      while not world.epoch_done() and cnt < max_cnt:
          cnt += opt.get("batchsize", 1)
          world.parley()
          if world_logger is not None:
              world_logger.log(world)
          if opt["display_examples"]:
              # display examples
              print(world.display() + "\n~~")
          if log_time.time() > log_every_n_secs:
              report = world.report()
              text, report = log_time.log(
                  report.get("exs", 0), min(max_cnt, total_cnt), report
              )
              logging.info(text)
  
      if world_logger is not None:
          # dump world acts to file
          world_logger.reset()  # add final acts to logs
          if is_distributed():
              rank = get_rank()
              base_outfile, extension = os.path.splitext(
                  task_opt["world_logs"]
              )
              outfile = base_outfile + f"_{rank}" + extension
          else:
              outfile = task_opt["world_logs"]
          world_logger.write(
              outfile, world, file_format=opt["save_format"]
          )
  
      report = aggregate_unnamed_reports(
          all_gather_list(world.report())
      )
  
      if isinstance(world.agents, list) and len(world.agents) > 1:
          classifier_agent = world.agents[CLASSIFIER_AGENT]
          if (
              hasattr(classifier_agent, "calc_auc")
              and classifier_agent.calc_auc
          ):
              for class_indices, curr_auc in zip(
                  classifier_agent.auc_class_indices,
                  classifier_agent.aucs,
              ):
                  report[
                      f"AUC_{classifier_agent.class_list[class_indices]}"
                  ] = curr_auc
              classifier_agent.reset_auc()
              # for safety measures
              agent.reset_auc()
      world.reset()
      return report
  
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 6 for calling a global function with example usage: _eval_single_world(opt, agent, task) and returns: report