human
Write me a Python code to determine    whether    to    retry,\n                based    on    the    arguments    to    the    callback given the following:
I wrote the below code

    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)

What's a good function header?
assistant
#Here is Python code to determine    whether    to    retry,\n                based    on    the    arguments    to    the    callback.

def CallWithRetryAsync(retry_policy, func, *args, **kwargs):