code: def ensure_directory(directory):
      
      directory = os.path.expanduser(directory)
      try:
          os.makedirs(directory)
      except OSError as e:
          if e.errno != errno.EEXIST:
              raise e
docs: Create the directories along the provided directory path that do not exist.