def _get_nearest_labels_for(self, labels):
    if (len(labels) == 0):
        tags = self.get_current_label_dictionary().get_items()
        import random
        sample = random.sample(tags, k=self.num_negative_labels_to_sample)
        return sample
    already_sampled_negative_labels = set()
    for label in labels:
        plausible_labels = []
        plausible_label_probabilities = []
        for plausible_label in self.label_nearest_map[label]:
            if ((plausible_label in already_sampled_negative_labels) or (plausible_label in labels)):
                continue
            else:
                plausible_labels.append(plausible_label)
                plausible_label_probabilities.append(self.label_nearest_map[label][plausible_label])
        plausible_label_probabilities = np.array(plausible_label_probabilities, dtype='float64')
        plausible_label_probabilities += 1e-08
        plausible_label_probabilities /= np.sum(plausible_label_probabilities)
        if (len(plausible_labels) > 0):
            num_samples = min(self.num_negative_labels_to_sample, len(plausible_labels))
            sampled_negative_labels = np.random.choice(plausible_labels, num_samples, replace=False, p=plausible_label_probabilities)
            already_sampled_negative_labels.update(sampled_negative_labels)
    return already_sampled_negative_labels
def _get_nearest_labels_for(self, labels):
    if (len(labels) == 0):
        tags = self.get_current_label_dictionary().get_items()
        import random
        sample = random.sample(tags, k=self.num_negative_labels_to_sample)
        return sample
    already_sampled_negative_labels = set()
    for label in labels:
        plausible_labels = []
        plausible_label_probabilities = []
        for plausible_label in self.label_nearest_map[label]:
            if ((plausible_label in already_sampled_negative_labels) or (plausible_label in labels)):
                continue
            else:
                plausible_labels.append(plausible_label)
                plausible_label_probabilities.append(self.label_nearest_map[label][plausible_label])
        plausible_label_probabilities = np.array(plausible_label_probabilities, dtype='float64')
        plausible_label_probabilities += 1e-08
        plausible_label_probabilities /= np.sum(plausible_label_probabilities)
        if (len(plausible_labels) > 0):
            num_samples = min(self.num_negative_labels_to_sample, len(plausible_labels))
            sampled_negative_labels = np.random.choice(plausible_labels, num_samples, replace=False, p=plausible_label_probabilities)
            already_sampled_negative_labels.update(sampled_negative_labels)
    return already_sampled_negative_labels