def METHOD_NAME(values, k, dim=0, sorted=True, largest=True):
    r"""Selects topk as in torch.topk but does not bias lower indices when values are equal.
    Args:
        values: (torch.Tensor)
            Values to index into.
        k: (int):
            Number to take.
    Return:
        topk: (torch.Tensor):
            topk k values.
        indices: (torch.LongTensor)
            indices of the topk values.
    """
    permutation = torch.randperm(values.shape[dim])
    permuted_values = values[permutation]
    topk, indices = torch.topk(
        permuted_values, k, dim=dim, sorted=sorted, largest=largest
    )
    return topk, permutation[indices]