public Optional<byte[]> getSerializedTensor() {
        if (serializedTensor.isPresent()) {
            return serializedTensor;
        } else if (tensor.isPresent()) {
            serializedTensor = Optional.of(TypedBinaryFormat.encode(tensor.get()));
            assert(serializedTensor.isPresent());
        }
        return serializedTensor;
    }
Create a tensor field value containing the given tensor
document/src/main/java/com/yahoo/document/datatypes/TensorFieldValue.java