code: def del_dir(target: Union[Path, str], only_if_empty: bool = False):
      target = Path(target).expanduser()
      assert target.is_dir()
      for p in sorted(target.glob("**/*"), reverse=True):
          if not p.exists():
              continue
          p.chmod(0o666)
          if p.is_dir():
              p.rmdir()
          else:
              if only_if_empty:
                  raise RuntimeError(f"{p.parent} is not empty!")
              p.unlink()
      target.rmdir()
  
file_path: tvm/apps/android_camera/models/prepare_model.py
imports: import logging
  import pathlib
  from pathlib import Path
  from typing import Union
  import os
  from os import environ
  import json
  import tvm
  import tvm.relay
  from tvm.contrib import utils, ndk, graph_executor
  from tvm.contrib.download import download_testdata, download
label_desc: Use image node_id 1 for calling a global function with example usage: del_dir(target, only_if_empty) without return types