def compute_topics_similarity_matrix(papers_vectors, comps):
    logger.debug('Computing mean similarity between topics embeddings')
    n_comps = len(set(comps))
    distances = pairwise_distances(papers_vectors)
    similarity_matrix = np.zeros(shape=(n_comps, n_comps))
    indx = {i: np.flatnonzero([(c == i) for c in comps]).tolist() for i in range(n_comps)}
    for i in range(n_comps):
        for j in range(i, n_comps):
            mean_distance = np.mean(distances[indx[i], :][:, indx[j]])
            similarity_matrix[(i, j)] = similarity_matrix[(j, i)] = (1 / (1 + mean_distance))
    return similarity_matrix
def compute_topics_similarity_matrix(papers_vectors, comps):
    logger.debug('Computing mean similarity between topics embeddings')
    n_comps = len(set(comps))
    distances = pairwise_distances(papers_vectors)
    similarity_matrix = np.zeros(shape=(n_comps, n_comps))
    indx = {i: np.flatnonzero([(c == i) for c in comps]).tolist() for i in range(n_comps)}
    for i in range(n_comps):
        for j in range(i, n_comps):
            mean_distance = np.mean(distances[indx[i], :][:, indx[j]])
            similarity_matrix[(i, j)] = similarity_matrix[(j, i)] = (1 / (1 + mean_distance))
    return similarity_matrix