def METHOD_NAME(link_label):
    """Validate the given link label.
    Valid link labels adhere to the following restrictions:
        * Has to be a valid python identifier
        * Can only contain alphanumeric characters and underscores
        * Can not start or end with an underscore
    :raises TypeError: if the link label is not a string type
    :raises ValueError: if the link label is invalid
    """
    import re
    message = f'invalid link label `{link_label}`: should be string type but is instead: {type(link_label)}'
    type_check(link_label, str, message)
    allowed_character_set = '[a-zA-Z0-9_]'
    if link_label.endswith('_'):
        raise ValueError('cannot end with an underscore')
    if link_label.startswith('_'):
        raise ValueError('cannot start with an underscore')
    if re.sub(allowed_character_set, '', link_label):
        raise ValueError('only alphanumeric and underscores are allowed')
    if not isidentifier(link_label):
        raise ValueError('not a valid python identifier')