code: def _check_log_dir(dir: Optional[str]):
      if dir is None:
          raise RuntimeError(
              "Must specify log directory via `--log-folder <path to folder>`"
          )
  
      if not os.path.exists(dir):
          logging.warning(
              f"[ Directory {dir} does not exist, creating... ]"
          )
          os.makedirs(dir)
  
      return
  
file_path: ParlAI/projects/safety_bench/run_unit_tests.py
imports: from parlai.core.params import ParlaiParser
  from parlai.core.script import ParlaiScript
  import parlai.utils.logging
  from projects.safety_bench.utils.wrapper_loading import load_wrapper_module, setup_wrapper_registry, register_model_wrapper, MODEL_WRAPPER_REGISTRY
  from projects.safety_bench.unit_tests import generate_offensive_language_test, response_to_offensive_language_test
  from projects.safety_bench.utils.colors import color
  from projects.safety_bench.utils.perspective_api import get_perspective_api_key
  import os
  from typing import Optional
label_desc: Use image node_id 3 for calling a global function with example usage: _check_log_dir(dir) without return types