private static TensorType.Value decodeValueType(GrowableByteBuffer buffer) {
        int valueType = buffer.getInt1_4Bytes();
        switch (valueType) {
            case DOUBLE_VALUE_TYPE: return TensorType.Value.DOUBLE;
            case FLOAT_VALUE_TYPE: return TensorType.Value.FLOAT;
            case BFLOAT16_VALUE_TYPE: return TensorType.Value.BFLOAT16;
            case INT8_VALUE_TYPE: return TensorType.Value.INT8;
        }
        throw new IllegalArgumentException("Received tensor value type '" + valueType + "'. " +
                "Only 0(double), 1(float), 2(bfloat16), or 3(int8) is legal.");
    }
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