human
Complete this python program:
def ensure_valid_usage_key(view_func):
assistant
#Here is the Python program you requested.

    """This decorator should only be used with views which have argument usage_key_string.
    If usage_key_string is not valid raise 404.
    """
    @wraps(view_func)
    def inner(request, *args, **kwargs):
        usage_key = kwargs.get('usage_key_string')
        if (usage_key is not None):
            try:
                UsageKey.from_string(usage_key)
            except InvalidKeyError:
                raise Http404
        response = view_func(request, *args, **kwargs)
        return response
    return inner