### Question:
GraphOperationBuilder implements OperationBuilder { private static void setAttrShape(TF_OperationDescription handle, String name, long[] shape, int numDims) { requireHandle(handle); TF_SetAttrShape(handle, name, shape, numDims); } 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 setAttrShape() { try (Graph g = new Graph()) { Output<?> n = g.opBuilder("Placeholder", "unknown") .setAttr("dtype", TFloat32.DTYPE) .setAttr("shape", Shape.unknown()) .build() .output(0); assertEquals(-1, n.shape().numDimensions()); assertEquals(TFloat32.DTYPE, n.dataType()); n = g.opBuilder("Placeholder", "batch_of_vectors") .setAttr("dtype", TFloat32.DTYPE) .setAttr("shape", Shape.of(-1, 784)) .build() .output(0); assertEquals(2, n.shape().numDimensions()); assertEquals(-1, n.shape().size(0)); assertEquals(784, n.shape().size(1)); assertEquals(TFloat32.DTYPE, n.dataType()); } }