def token_distance(t1, t2, initial_match_penalization):
    """Calculates the edit distance between two tokens."""
    if isinstance(t1, NameInitial) or isinstance(t2, NameInitial):
        if t1.token == t2.token:
            return 0
        if t1 == t2:
            return initial_match_penalization
        return 1.0
    return _normalized_edit_dist(t1.token, t2.token)
Calculates the edit distance between two tokens.