### Question:
GraphOperationBuilder implements OperationBuilder { @Override public GraphOperationBuilder addControlInput(Operation control) { if (!(control instanceof GraphOperation)) { throw new IllegalArgumentException( "Only GraphOperation instances can be used as control inputs"); } Graph.Reference r = graph.ref(); try { addControlInput(unsafeNativeHandle, ((GraphOperation) control).getUnsafeNativeHandle()); } finally { r.close(); } return this; } GraphOperationBuilder(Graph graph, String type, String name); @Override GraphOperation build(); @Override GraphOperationBuilder addControlInput(Operation control); @Override GraphOperationBuilder addInput(Output<?> input); @Override GraphOperationBuilder addInputList(Output<?>[] inputs); @Override GraphOperationBuilder setDevice(String device); @Override GraphOperationBuilder setAttr(String name, String value); @Override GraphOperationBuilder setAttr(String name, byte[] value); @Override GraphOperationBuilder setAttr(String name, long value); @Override GraphOperationBuilder setAttr(String name, long[] value); @Override GraphOperationBuilder setAttr(String name, float value); @Override GraphOperationBuilder setAttr(String name, float[] value); @Override GraphOperationBuilder setAttr(String name, boolean value); @Override GraphOperationBuilder setAttr(String name, boolean[] value); @Override GraphOperationBuilder setAttr(String name, DataType value); @Override GraphOperationBuilder setAttr(String name, DataType[] value); @Override GraphOperationBuilder setAttr(String name, Tensor<?> value); @Override GraphOperationBuilder setAttr(String name, Tensor<?>[] value); @Override GraphOperationBuilder setAttr(String name, Shape value); @Override GraphOperationBuilder setAttr(String name, Shape[] value); @Override GraphOperationBuilder setAttr(String name, String[] value);  }### Answer:
@Test public void addControlInput() { try (Graph g = new Graph(); Session s = new Session(g); Tensor<TBool> yes = TBool.scalarOf(true); Tensor<TBool> no = TBool.scalarOf(false)) { Ops tf = Ops.create(g); Output<TBool> placeholder = tf.placeholder(TBool.DTYPE).asOutput(); GraphOperation check = g.opBuilder("Assert", "assert") .addInput(placeholder) .addInputList(new Output<?>[] {placeholder}) .build(); Operation noop = g.opBuilder("NoOp", "noop").addControlInput(check).build(); s.runner().feed(placeholder, yes).addTarget(noop).run(); try { s.runner().feed(placeholder, no).addTarget(noop).run(); fail("Did not run control operation."); } catch (TFInvalidArgumentException e) { } } }