def ensuredir(dpath, mode=<NUM_LIT>, verbose=None):
if verbose is None:  <EOL><INDENT>verbose = <NUM_LIT:0><EOL><DEDENT>if isinstance(dpath, (list, tuple)):  <EOL><INDENT>dpath = join(*dpath)<EOL><DEDENT>if not exists(dpath):<EOL><INDENT>if verbose:  <EOL><INDENT>print('<STR_LIT>' % dpath)<EOL><DEDENT>if sys.version_info.major == <NUM_LIT:2>:  <EOL><INDENT>os.makedirs(normpath(dpath), mode=mode)<EOL><DEDENT>else:<EOL><INDENT>os.makedirs(normpath(dpath), mode=mode, exist_ok=True)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if verbose:  <EOL><INDENT>print('<STR_LIT>' % dpath)<EOL><DEDENT><DEDENT>return dpath<EOL>
r"""
    Ensures that directory will exist. Creates new dir with sticky bits by
    default

    Args:
        dpath (PathLike): dir to ensure. Can also be a tuple to send to join
        mode (int): octal mode of directory (default 0o1777)
        verbose (int): verbosity (default 0)

    Returns:
        PathLike: path: the ensured directory

    Notes:
        This function is not thread-safe in Python2

    Example:
        >>> from ubelt.util_platform import *  # NOQA
        >>> import ubelt as ub
        >>> cache_dpath = ub.ensure_app_cache_dir('ubelt')
        >>> dpath = join(cache_dpath, 'ensuredir')
        >>> if exists(dpath):
        ...     os.rmdir(dpath)
        >>> assert not exists(dpath)
        >>> ub.ensuredir(dpath)
        >>> assert exists(dpath)
        >>> os.rmdir(dpath)