code: def safe_rm(path_to_rm):
      """
      Safely remove a directory of files or a file
      1.) check path exists, files are files, dirs are dirs
      2.) only remove things on approved list REMOVABLE_PATHS
      3.) assert no longer exists
      """
      # just return if path doesn't exist
      if not os.path.exists(path_to_rm):
          return
      # handle directory
      if os.path.isdir(path_to_rm):
          files_to_rm = [
              f"{path_to_rm}/{fname}"
              for fname in os.listdir(path_to_rm)
          ]
          dir_to_rm = path_to_rm
      else:
          files_to_rm = [path_to_rm]
          dir_to_rm = None
      # clear out files
      for file_to_rm in files_to_rm:
          if (
              os.path.isfile(file_to_rm)
              and os.path.basename(file_to_rm) in REMOVABLE_PATHS
          ):
              os.remove(file_to_rm)
              assert not os.path.exists(
                  file_to_rm
              ), f"Error removing: {file_to_rm}"
      # clear out directory
      if dir_to_rm is not None and os.path.isdir(dir_to_rm):
          os.rmdir(dir_to_rm)
          assert not os.path.exists(
              dir_to_rm
          ), f"Error removing: {dir_to_rm}"
  
imports: import os
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: safe_rm(path_to_rm) without return types