code: def emptydirs(path, noexist_ok=False):
      """
      Empty an existing directory, without deleting it. Do not
      raise error if the path does not exist and noexist_ok is True.
  
      Parameters
      ----------
      path : directory that should be empty
  
      """
      fmlogger.debug("Removing contents of %s", path)
  
      if noexist_ok and not op.exists(path):
          return True
  
      if op.isfile(path):
          raise OSError('path "%s" should be a directory' % path)
  
      try:
          shutil.rmtree(path)
      except OSError as ex:
          elcont = [
              Path(root) / file
              for root, _, files in os.walk(path)
              for file in files
              if not file.startswith(".nfs")
          ]
          if ex.errno in [errno.ENOTEMPTY, errno.EBUSY] and not elcont:
              fmlogger.warning(
                  "An exception was raised trying to remove old %s, but the path"
                  " seems empty. Is it an NFS mount?. Passing the exception.",
                  path,
              )
          elif ex.errno == errno.ENOTEMPTY and elcont:
              fmlogger.debug(
                  "Folder %s contents (%d items).", path, len(elcont)
              )
              raise ex
          else:
              raise ex
  
      os.makedirs(path, exist_ok=True)
  
imports: import sys
  import pickle
  import errno
  import subprocess
  import gzip
  import hashlib
  import locale
  from hashlib import md5
  import os
  import os.path
  import re
  import shutil
  import contextlib
  import posixpath
  from pathlib import Path
  import simplejson
  from time import sleep, time
  from ..None import logging, config, __version__
  from .misc import is_container
label_desc: Use image node_id 28 for calling a global function with example usage: emptydirs(path, noexist_ok) and returns: True