human
Complete the below
def CallWithRetryAsync(retry_policy, func, *args, **kwargs):

    ''''This is a higher-order function that wraps an arbitrary asynchronous
    function (plus its arguments) in order to add retry functionality. If the
    wrapped function completes with an error, then CallWithRetryAsync may call
    it again. Pass a "retry_policy" argument that derives from RetryPolicy in
    order to control the retry behavior. The retry policy determines whether
    the function completed with a retry-able error, and then decides how many
    times to retry, and how frequently to retry.'
    '''
assistant
#Here is the Python code you requested.
    inner_callback = kwargs.get('callback', None)
    assert ('callback' in kwargs), 'CallWithRetryAsync    requires    a    named    "callback"    argument    that    is    not    None.'
    retry_manager = retry_policy.CreateManager()
    def _OnCompletedCall(*callback_args, **callback_kwargs):
        'Called    when    the    operation    has    completed.    Determine    whether    to    retry,\n                based    on    the    arguments    to    the    callback.\n                '
        retry_func = functools.partial(func, *args, **kwargs)
        if (not retry_manager.MaybeRetryOnResult(retry_func, *callback_args, **callback_kwargs)):
            exception_context.check_retry = False
            inner_callback(*callback_args, **callback_kwargs)
    def _OnException(type, value, tb):
        'Called    if    the    operation    raises    an    exception.    Determine    whether    to    retry\n                or    re-raise    the    exception,    based    on    the    exception    details.\n                '
        if exception_context.check_retry:
            retry_func = functools.partial(func, *args, **kwargs)
            return retry_manager.MaybeRetryOnException(retry_func, type, value, tb)
    kwargs['callback'] = _OnCompletedCall
    exception_context = ExceptionStackContext(_OnException)
    exception_context.check_retry = True
    with exception_context:
        func(*args, **kwargs)