def _shared_family_map(pg_data: dict, name_mapping: dict) -> dict:
    """
    Calculate the number of shared ortholog families between any two genomes
    Args:
        pg_data: workspace data object for the Pangenome
        name_mapping: mapping of workspace ref to readable name for use as keys
    Returns:
        dict where keys are genome refs, and values are mapping of genome refs
        to shared family counts.
        Example: {"1": {"2": 10}} represents genome "1" and "2" sharing 10
        families
    """
    # Initialize the return structure
    ret = {}
    for ref1 in pg_data["genome_refs"]:
        key1 = name_mapping[ref1]
        ret[key1] = {}
        for ref2 in pg_data["genome_refs"]:
            key2 = name_mapping[ref2]
            ret[key1][key2] = 0
    # Aggregate counts of all genomes that share genes in an ortholog family
    for family in pg_data["orthologs"]:
        if len(family["orthologs"]) <= 1:
            # We only record non-singletons
            continue
        genome_refs = set(orth[2] for orth in family["orthologs"])
        for ref1 in genome_refs:
            for ref2 in genome_refs:
                key1, key2 = name_mapping[ref1], name_mapping[ref2]
                ret[key1][key2] += 1
    return ret