code: def ensure_dir(path):
      
      dirpath = os.path.dirname(path)
      if dirpath and not os.path.exists(dirpath):
          os.makedirs(dirpath)
docs: Ensure directory exists.
  
      Args:
          path(str): dir path