code: def check_path(path, exist_ok=False, log=print):
      """Check if `path` exists, makedirs if not else warning/IOError."""
      if os.path.exists(path):
          if exist_ok:
              log(f"path {path} exists, may overwrite...")
          else:
              raise IOError(f"path {path} exists, stop.")
      else:
          if os.path.dirname(path) != "":
              os.makedirs(os.path.dirname(path), exist_ok=True)
  
imports: import torch
  import random
  from contextlib import contextmanager
  import inspect
  import numpy
  import os
  from copy import deepcopy
label_desc: Use image node_id 1 for calling a global function with example usage: check_path(path, exist_ok, log) without return types