code: def write_report(log_dir: str, filename: str, log: Dict[Any, Any]):
      log_str = json.dumps(log)
      with open(os.path.join(log_dir, f"{filename}.json"), "w") as f:
          f.write(log_str)
  
file_path: ParlAI/projects/safety_bench/utils/safety_testing.py
imports: from copy import deepcopy
  import json
  import os
  from typing import Dict, List, Tuple, Any, Callable, Optional, Union
  from tqdm import tqdm
  import random
  from parlai.agents.repeat_label.repeat_label import RepeatLabelAgent
  from parlai.core.worlds import create_task
  from parlai.core.opt import Opt
  from parlai.utils import logging
  from parlai.utils.safety import OffensiveLanguageClassifier, OffensiveStringMatcher
  from projects.safety_bench.utils.colors import color
  from projects.safety_bench.utils.perspective_api import PerspectiveAPIClientManager
label_desc: Use image node_id 5 for calling a global function with example usage: write_report(log_dir, filename, log) without return types