code: def clean_tarfile(file_path: str, mode: str) -> None:
      """This utility removes all files extracted from a tarfile."""
      if not os.path.exists(file_path):
          return
  
      with tarfile.open(file_path, mode=mode) as tar_ref:
          for member in tar_ref.getmembers():
              p = member.path
              if p == "." or not os.path.exists(p):
                  continue
              try:
                  if os.path.isfile(p):
                      os.remove(p)
                  else:
                      shutil.rmtree(p)
              except (FileNotFoundError, OSError, PermissionError):
                  pass
  
      if os.path.exists(file_path):
          os.remove(file_path)
  
imports: import os
  import shutil
  import tarfile
label_desc: Use image node_id 1 for calling a global function with example usage: clean_tarfile(file_path, mode) without return types