private static void encodeValueType(GrowableByteBuffer buffer, TensorType.Value valueType) {
        switch (valueType) {
            case DOUBLE -> buffer.putInt1_4Bytes(DOUBLE_VALUE_TYPE);
            case FLOAT -> buffer.putInt1_4Bytes(FLOAT_VALUE_TYPE);
            case BFLOAT16 -> buffer.putInt1_4Bytes(BFLOAT16_VALUE_TYPE);
            case INT8 -> buffer.putInt1_4Bytes(INT8_VALUE_TYPE);
            default -> throw new IllegalArgumentException("Attempt to encode unknown tensor value type: " + valueType);
        }
    }
Decode some data to a tensor

@param type the type to decode and validate to, or empty to use the type given in the data
@param buffer the buffer containing the data, use GrowableByteByffer.wrap(byte[]) if you have a byte array
@return the resulting tensor
@throws IllegalArgumentException if the tensor data was invalid
vespajlib/src/main/java/com/yahoo/tensor/serialization/TypedBinaryFormat.java