### Question:
Tensor implements AutoCloseable { static Tensor<?> fromHandle(TF_Tensor handle) { Tensor<?> t = new Tensor<>(DataTypes.fromNativeCode(dtype(handle)), Shape.of(shape(handle))); try (PointerScope scope = new PointerScope()) { scope.attach(handle); t.tensorHandle = handle; t.tensorScope = scope.extend(); } return t; } private  Tensor(DataType<T> dtype, Shape shape); static Tensor<T> of(DataType<T> dtype, Shape shape); static Tensor<T> of(DataType<T> dtype, Shape shape, long size); static Tensor<T> of(DataType<T> dtype, Shape shape,
      Consumer<T> dataInitializer); static Tensor<T> of(DataType<T> dtype, Shape shape, long size,
      Consumer<T> dataInitializer); static Tensor<T> of(DataType<T> dtype, Shape shape, ByteDataBuffer rawData); @SuppressWarnings("unchecked") Tensor<U> expect(DataType<U> dt); @Override void close(); DataType<T> dataType(); long numBytes(); Shape shape(); T data(); ByteDataBuffer rawData(); @Override String toString();  }### Answer:
@Test public void fromHandle() { final FloatNdArray matrix = StdArrays.ndCopyOf(new float[][]{{1, 2, 3}, {4, 5, 6}}); try (Tensor<TFloat32> src = TFloat32.tensorOf(matrix)) { Tensor<TFloat32> cpy = Tensor.fromHandle(src.nativeHandle()).expect(TFloat32.DTYPE); assertEquals(src.dataType(), cpy.dataType()); assertEquals(src.shape().numDimensions(), cpy.shape().numDimensions()); assertEquals(src.shape(), cpy.shape()); assertEquals(matrix, cpy.data()); } }