### Question:
DatasetIterator implements Iterable<List<Operand<?>>> { public List<Operand<?>> getNext() { List<Operand<?>> components = new ArrayList<>(); tf.data .iteratorGetNext(getIteratorResource(), outputTypes, outputShapes) .iterator() .forEachRemaining(components::add); return components; } DatasetIterator(
      Ops tf,
      Operand<?> iteratorResource,
      Op initializer,
      List<DataType<?>> outputTypes,
      List<Shape> outputShapes);  DatasetIterator(
      Ops tf,
      Operand<?> iteratorResource,
      List<DataType<?>> outputTypes,
      List<Shape> outputShapes); protected  DatasetIterator(DatasetIterator other); List<Operand<?>> getNext(); DatasetOptional getNextAsOptional(); Op makeInitializer(Dataset dataset); static DatasetIterator fromStructure(
      Ops tf, List<DataType<?>> outputTypes, List<Shape> outputShapes); Operand<?> getIteratorResource(); Op getInitializer(); Ops getOpsInstance(); @Override Iterator<List<Operand<?>>> iterator(); static final String EMPTY_SHARED_NAME; }### Answer:
@Test public void testGraphIteration() { try (Graph graph = new Graph()) { Ops tf = Ops.create(graph); List<Operand<?>> tensors = Arrays.asList(tf.constant(testMatrix1), tf.constant(testMatrix2)); List<DataType<?>> dataTypes = Arrays.asList(TInt32.DTYPE, TInt32.DTYPE); Dataset dataset = Dataset.fromTensorSlices(tf, tensors, dataTypes); DatasetIterator iterator = dataset.makeOneShotIterator(); List<Operand<?>> components = iterator.getNext(); Operand<?> x = components.get(0); Operand<?> y = components.get(1); try (Session session = new Session(graph)) { session.run(tf.init()); int batches = 0; while (true) { try { List<Tensor<?>> outputs = session.runner().fetch(x).fetch(y).run(); try (Tensor<TInt32> xBatch = outputs.get(0).expect(TInt32.DTYPE); Tensor<TInt32> yBatch = outputs.get(1).expect(TInt32.DTYPE)) { assertEquals(testMatrix1.get(batches), xBatch.data()); assertEquals(testMatrix2.get(batches), yBatch.data()); batches++; } } catch (TFOutOfRangeException e) { break; } } } } }