def user_loc_value_to_class(axis_tag, user_loc):
if axis_tag == "<STR_LIT>":<EOL><INDENT>return int(user_loc)<EOL><DEDENT>elif axis_tag == "<STR_LIT>":<EOL><INDENT>return min(<EOL>sorted(WIDTH_CLASS_TO_VALUE.items()),<EOL>key=lambda item: abs(item[<NUM_LIT:1>] - user_loc),<EOL>)[<NUM_LIT:0>]<EOL><DEDENT>raise NotImplementedError<EOL>
Return the OS/2 weight or width class that is closest to the provided
    user location. For weight the user location is between 0 and 1000 and for
    width it is a percentage.

    >>> user_loc_value_to_class('wght', 310)
    310
    >>> user_loc_value_to_class('wdth', 62)
    2