async def desync(
    func: CallableMaybeAwaitable[A, T], *args, **kwargs
) -> T:  # effectively Awaitable[T]:
    """
    Run the given function asynchronously with the given args. If it is not
    asynchronous, will run in thread. Note: this has to be marked async since in
    some cases we cannot tell ahead of time that `func` is asynchronous so we
    may end up running it to produce a coroutine object which we then need to
    run asynchronously.
    """

    if python_utils.is_really_coroutinefunction(func):
        return await func(*args, **kwargs)

    else:
        res = await asyncio.to_thread(func, *args, **kwargs)

        # HACK010: Might actually have been a coroutine after all.
        if inspect.iscoroutine(res):
            return await res
        else:
            return res

    Run the given function asynchronously with the given args. If it is not
    asynchronous, will run in thread. Note: this has to be marked async since in
    some cases we cannot tell ahead of time that `func` is asynchronous so we
    may end up running it to produce a coroutine object which we then need to
    run asynchronously.
    
src/core/trulens/core/utils/asynchro.py