human
Complete the below
@utils.expects_func_args('image_id', 'instance')
def delete_image_on_error(function):

    ''''Used for snapshot related method to ensure the image created in
    compute.api is deleted when an error occurs.'
    '''
assistant
#Here is the Python program you requested.
    @functools.wraps(function)
    def decorated_function(self, context, image_id, instance, *args, **kwargs):
        try:
            return function(self, context, image_id, instance, *args, **kwargs)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.debug('Cleaning    up    image    %s', image_id, exc_info=True, instance=instance)
                try:
                    self.image_api.delete(context, image_id)
                except exception.ImageNotFound:
                    pass
                except Exception:
                    LOG.exception('Error    while    trying    to    clean    up    image    %s', image_id, instance=instance)
    return decorated_function