code: def write_log(
      log_dir: str,
      filename: str,
      inp_lst: List[str],
      out_lst: List[str],
      score_lst: List[str],
  ):
      """
      Write a log of model inputs, outputs, scores.
      """
      to_write = os.path.join(log_dir, filename) + ".txt"
      logging.info(f"Writing log to {to_write}")
      with open(to_write, "w") as f:
          i = 0
          for inp, out, score in zip(inp_lst, out_lst, score_lst):
              f.write(
                  f"<example. no>:\t{i + 1}\n<in>:\t{inp}\n<out>:\t{out}\n<scores>:\t{score}\n\n"
              )
              i += 1
  
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 4 for calling a global function with example usage: write_log(log_dir, filename, inp_lst, out_lst, score_lst) without return types