### Question:
IndexFn implements Iterable<Integer> { IndexFn section(List<Range> ranges) throws InvalidRangeException { Preconditions.checkArgument(ranges.size() == rank); for (int ii = 0; ii < rank; ii++) { Range r = ranges.get(ii); if (r == null) continue; if (r == Range.VLEN) continue; if ((r.first() < 0) || (r.first() >= shape[ii])) throw new InvalidRangeException("Bad range starting value at index " + ii + " == " + r.first()); if ((r.last() < 0) || (r.last() >= shape[ii])) throw new InvalidRangeException("Bad range ending value at index " + ii + " == " + r.last()); } IndexFn.Builder newindex = builder(rank); newindex.offset = offset; int[] newstride = new int[rank]; for (int ii = 0; ii < rank; ii++) { Range r = ranges.get(ii); if (r == null) { newindex.shape[ii] = shape[ii]; newstride[ii] = stride[ii]; } else { newindex.shape[ii] = r.length(); newstride[ii] = stride[ii] * r.stride(); newindex.offset += stride[ii] * r.first(); } } newindex.setStride(newstride); newindex.canonicalOrder = canonicalOrder && (Arrays.computeSize(newindex.shape) == size); return newindex.build(); } private  IndexFn(Builder builder); int get(int... index); int getRank(); Section getSection(); int[] getShape(); int getShape(int index); Iterator<Integer> iterator(); Iterator<Integer> iterator(int start, long length); long length(); String toString(); static Builder builder(int rank); static Builder builder(int[] shape); Builder toBuilder();  }### Answer:
@Test public void testSection() throws InvalidRangeException { int[] shape = new int[] {100}; IndexFn index = IndexFn.builder(shape).build(); IndexFn subset = index.section(ImmutableList.of(new Range(11, 15))); assertThat(subset.toString()).isEqualTo("11, 12, 13, 14, 15"); assertThat(subset.getRank()).isEqualTo(1); assertThat(subset.getShape()).isEqualTo(new int[] {5}); assertThat(subset.length()).isEqualTo(5); }