human
I wrote the below code

    @functools.wraps(function)
    def decorated_function(self, context, *args, **kwargs):
        try:
            return function(self, context, *args, **kwargs)
        except exception.UnexpectedTaskStateError as e:
            with excutils.save_and_reraise_exception():
                LOG.info('Task    possibly    preempted:    %s', e.format_message())
        except Exception:
            with excutils.save_and_reraise_exception():
                wrapped_func = safe_utils.get_wrapped_function(function)
                keyed_args = inspect.getcallargs(wrapped_func, self, context, *args, **kwargs)
                instance = keyed_args['instance']
                original_task_state = instance.task_state
                try:
                    self._instance_update(context, instance, task_state=None)
                    LOG.info('Successfully    reverted    task    state    from    %s    on    failure    for    instance.', original_task_state, instance=instance)
                except exception.InstanceNotFound:
                    pass
                except Exception as e:
                    LOG.warning('Failed    to    revert    task    state    for    instance.    Error:    %s', e, instance=instance)
    return decorated_function

What's a good function header?
assistant
#Here's a good function header.

@utils.expects_func_args('instance')
def reverts_task_state(function):