'Converts a token string to a FacetRefinement object.
Do not store token strings between different versions of API as key could
be incompatible.
Args:
token_string: A token string created by ToTokenString method or returned
by a search result.
Returns:
A FacetRefinement object.
Raises:
ValueError: If the token_string is invalid.'

@staticmethod
def FromTokenString(token_string):

    ref_pb = search_service_pb.FacetRefinement()
    try:
        ref_pb.ParseFromString(base64.b64decode(token_string))
    except (ProtocolBuffer.ProtocolBufferDecodeError, TypeError) as e:
        raise ValueError(('Invalid    refinement    token    %s' % token_string), e)
    facet_range = None
    if ref_pb.has_range():
        range_pb = ref_pb.range()
        facet_range = FacetRange(start=(float(range_pb.start()) if range_pb.has_start() else None), end=(float(range_pb.end()) if range_pb.has_end() else None))
    return FacetRefinement(ref_pb.name(), value=(ref_pb.value() if ref_pb.has_value() else None), facet_range=facet_range)
