public static <T extends Comparable<T>> Pair<Integer, T> argmax(List<T> values) {
        if (values.isEmpty()) {
            throw new IllegalArgumentException("argmax on an empty list");
        }
        //
        // There is no "globally min" value like -Inf for an arbitrary type T so we just pick the first list element
        T vmax = values.get(0);
        int imax = 0;
        for (int i = 1; i < values.size(); i++) {
            T v = values.get(i);
            if (v.compareTo(vmax) > 0) {
                vmax = v;
                imax = i;
            }
        }
        return new Pair<>(imax, vmax);
    }
@Test
    public void testArgmax() {
        assertThrows(IllegalArgumentException.class, () -> Util.argmax(new ArrayList<Double>()));

        List<Integer> lst = Collections.singletonList(1);
        Pair<Integer, Integer> argmax = Util.argmax(lst);
        assertEquals(0, argmax.getA());
        assertEquals(1, argmax.getB());

        lst = Arrays.asList(3, 2, 1);
        argmax = Util.argmax(lst);
        assertEquals(0, argmax.getA());
        assertEquals(3, argmax.getB());
    }