### Question:
TStringImpl extends DenseNdArray<String> implements TString { @Override public NdArray<byte[]> asBytes() { return NdArrays.wrap(shape(), tensorBuffer); } private  TStringImpl(
      StringTensorBuffer buffer, DataLayout<DataBuffer<byte[]>, String> layout, Shape shape); @Override TString using(Charset charset); @Override NdArray<byte[]> asBytes();  }### Answer:
@Test public void defaultCharsetIsUtf8() { Tensor<TString> tensor = TString.tensorOf(NdArrays.scalarOfObject(BABY_CHICK)); byte[] bytes = tensor.data().asBytes().getObject(); assertArrayEquals(new byte[] { (byte)0xF0, (byte)0x9F, (byte)0x90, (byte)0xA5 }, bytes); assertEquals(BABY_CHICK, tensor.data().getObject()); }
@Test public void initializingTensorWithRawBytes() { String[] strings = new String[] { "TensorFlow", "For", "Java", "Rocks", "!" }; NdArray<byte[]> bytes = NdArrays.ofObjects(byte[].class, Shape.of(strings.length)); for (int i = 0; i < strings.length; ++i) { bytes.setObject(strings[i].getBytes(), i); } Tensor<TString> tensor = TString.tensorOfBytes(bytes); assertNotNull(tensor); assertEquals(bytes.shape(), tensor.shape()); NdArray<byte[]> tensorBytes = tensor.data().asBytes(); for (int i = 0; i < strings.length; ++i) { assertArrayEquals(bytes.getObject(i), tensorBytes.getObject(i)); } }