import torch


def top_n_probs(predictions, k):
    """Get the top k, then remove all that are less than .75x as high probability as the most probable"""
    # Get the top k
    topk_probs, topk_indices = torch.topk(predictions, k)

    # Filter the top three to be only those that are at least .75x as likely as top1
    top_n_indices = []
    for prob, idx in zip(topk_probs, topk_indices):
        if prob / topk_probs[0] >= 0.75:
            top_n_indices.append(int(idx.detach().cpu().numpy()))
    return top_n_indices