def calculate_global_tanimoto_set_distances(dict_of_sets: Mapping[X, Set]) -> Mapping[X, Mapping[X, float]]:
universe = set(itt.chain.from_iterable(dict_of_sets.values()))<EOL>universe_size = len(universe)<EOL>result: Dict[X, Dict[X, float]] = defaultdict(dict)<EOL>for x, y in itt.combinations(dict_of_sets, <NUM_LIT:2>):<EOL><INDENT>result[x][y] = result[y][x] = <NUM_LIT:1.0> - len(dict_of_sets[x] | dict_of_sets[y]) / universe_size<EOL><DEDENT>for x in dict_of_sets:<EOL><INDENT>result[x][x] = <NUM_LIT:1.0> - len(x) / universe_size<EOL><DEDENT>return dict(result)<EOL>
r"""Calculate an alternative distance matrix based on the following equation.

    .. math:: distance(A, B)=1- \|A \cup B\| / \| \cup_{s \in S} s\|

    :param dict_of_sets: A dict of {x: set of y}
    :return: A similarity matrix based on the alternative tanimoto distance as a dict of dicts