def get_triplets(self, anom_idx, x, y, normal_label=0):
    self.x = x.cpu().data.numpy()
    self.y = y.cpu().data.numpy()
    anom_x = self.x[anom_idx]
    noml_idx = np.where((self.y == normal_label))[0]
    x_noml = self.x[noml_idx]
    n_neighbors = self.nbrs_num
    rand_num = self.rand_num
    nbrs_local = NearestNeighbors(n_neighbors=n_neighbors).fit(x_noml)
    nbr_indices = noml_idx[nbrs_local.kneighbors([anom_x])[1].flatten()]
    rand_canddt = np.setdiff1d(noml_idx, nbr_indices)
    rand_indices = np.random.choice(rand_canddt, rand_num, replace=False)
    triplets = [[anchor, positive, anom_idx] for anchor in rand_indices for positive in nbr_indices]
    target = ([[0, 0, 1]] * len(triplets))
    return (torch.LongTensor(np.array(triplets)), torch.LongTensor(np.array(target)))
def get_triplets(self, anom_idx, x, y, normal_label=0):
    self.x = x.cpu().data.numpy()
    self.y = y.cpu().data.numpy()
    anom_x = self.x[anom_idx]
    noml_idx = np.where((self.y == normal_label))[0]
    x_noml = self.x[noml_idx]
    n_neighbors = self.nbrs_num
    rand_num = self.rand_num
    nbrs_local = NearestNeighbors(n_neighbors=n_neighbors).fit(x_noml)
    nbr_indices = noml_idx[nbrs_local.kneighbors([anom_x])[1].flatten()]
    rand_canddt = np.setdiff1d(noml_idx, nbr_indices)
    rand_indices = np.random.choice(rand_canddt, rand_num, replace=False)
    triplets = [[anchor, positive, anom_idx] for anchor in rand_indices for positive in nbr_indices]
    target = ([[0, 0, 1]] * len(triplets))
    return (torch.LongTensor(np.array(triplets)), torch.LongTensor(np.array(target)))