human
Complete the below
def ensure_valid_course_key(view_func):

    ''''This decorator should only be used with views which have argument course_key_string (studio) or course_id (lms).
    If course_key_string (studio) or course_id (lms) is not valid raise 404.'
    '''
assistant
#Here is the Python code you requested.
    @wraps(view_func)
    def inner(request, *args, **kwargs):
        course_key = (kwargs.get('course_key_string') or kwargs.get('course_id'))
        if (course_key is not None):
            try:
                CourseKey.from_string(course_key)
            except InvalidKeyError:
                raise Http404
        response = view_func(request, *args, **kwargs)
        return response
    return inner