### Question:
RandomSearch { static List<List<?>> chooseHyperParameterCombos(Collection<? extends HyperParamValues<?>> ranges, int howMany) { Preconditions.checkArgument(howMany > 0); int numParams = ranges.size(); if (numParams == 0) { return Collections.singletonList(Collections.emptyList()); } RandomDataGenerator rdg = new RandomDataGenerator(RandomManager.getRandom()); List<List<?>> allCombinations = new ArrayList<>(howMany); for (int i = 0; i < howMany; i++) { List<Object> combination = new ArrayList<>(numParams); for (HyperParamValues<?> range : ranges) { combination.add(range.getRandomValue(rdg)); } allCombinations.add(combination); } return allCombinations; } private  RandomSearch();   }### Answer:
@Test public void testCombos() { List<HyperParamValues<?>> hyperParams = new ArrayList<>(); hyperParams.add(HyperParams.fixed(1.0)); hyperParams.add(HyperParams.range(2, 10)); hyperParams.add(HyperParams.around(5.0, 0.5)); List<List<?>> combos = RandomSearch.chooseHyperParameterCombos(hyperParams, 4); assertEquals(4, combos.size()); for (List<?> combo : combos) { assertEquals(1.0, combo.get(0)); assertTrue((Integer) combo.get(1) >= 2 && (Integer) combo.get(1) <= 10); assertTrue(Math.abs(((Double) combo.get(2)) - 5.0) <= 5.0 * 0.5); } }
@Test public void testNoCombos() { List<List<?>> combos = RandomSearch.chooseHyperParameterCombos(Collections.emptyList(), 1); assertEquals(1, combos.size()); assertEquals(0, combos.get(0).size()); }