def _compute_label_similarity_for_current_epoch(self):
    '\n        Compute the similarity between all labels for better sampling of negatives\n        '
    all_labels = [label.decode('utf-8') for label in self.get_current_label_dictionary().idx2item]
    label_sentences = [Sentence(label) for label in all_labels]
    self.tars_embeddings.eval()
    self.tars_embeddings.embed(label_sentences)
    self.tars_embeddings.train()
    if isinstance(self.tars_embeddings, TokenEmbeddings):
        encodings_np = [sentence[0].get_embedding().cpu().detach().numpy() for sentence in label_sentences]
    else:
        encodings_np = [sentence.get_embedding().cpu().detach().numpy() for sentence in label_sentences]
    normalized_encoding = minmax_scale(encodings_np)
    similarity_matrix = cosine_similarity(normalized_encoding)
    negative_label_probabilities = {}
    for (row_index, label) in enumerate(all_labels):
        negative_label_probabilities[label] = {}
        for (column_index, other_label) in enumerate(all_labels):
            if (label != other_label):
                negative_label_probabilities[label][other_label] = similarity_matrix[row_index][column_index]
    self.label_nearest_map = negative_label_probabilities
Compute the similarity between all labels for better sampling of negatives
def _compute_label_similarity_for_current_epoch(self):
    '\n        \n        '
    all_labels = [label.decode('utf-8') for label in self.get_current_label_dictionary().idx2item]
    label_sentences = [Sentence(label) for label in all_labels]
    self.tars_embeddings.eval()
    self.tars_embeddings.embed(label_sentences)
    self.tars_embeddings.train()
    if isinstance(self.tars_embeddings, TokenEmbeddings):
        encodings_np = [sentence[0].get_embedding().cpu().detach().numpy() for sentence in label_sentences]
    else:
        encodings_np = [sentence.get_embedding().cpu().detach().numpy() for sentence in label_sentences]
    normalized_encoding = minmax_scale(encodings_np)
    similarity_matrix = cosine_similarity(normalized_encoding)
    negative_label_probabilities = {}
    for (row_index, label) in enumerate(all_labels):
        negative_label_probabilities[label] = {}
        for (column_index, other_label) in enumerate(all_labels):
            if (label != other_label):
                negative_label_probabilities[label][other_label] = similarity_matrix[row_index][column_index]
    self.label_nearest_map = negative_label_probabilities