def nr_profiles(arr, genomes):
    """
    Get a condensed cgMLST pairwise distance matrix for specified Genomes_
    where condensed means redundant cgMLST profiles are only represented once in the distance matrix.

    Args:
        user_name (list): List of Genome_ names to retrieve condensed distance matrix for

    Returns:
        (numpy.array, list): tuple of condensed cgMLST distance matrix and list of grouped Genomes_
    """
    gs_collapse = []
    genome_idx_dict = {}
    indices = []
    patt_dict = {}
    for i, g in enumerate(genomes):
        p = arr[(i), :].tostring()
        if p in patt_dict:
            parent = patt_dict[p]
            idx = genome_idx_dict[parent]
            gs_collapse[idx].append(g)
        else:
            indices.append(i)
            patt_dict[p] = g
            genome_idx_dict[g] = len(gs_collapse)
            gs_collapse.append([g])
    return arr[(indices), :], gs_collapse
