static void fillTensor(TokenBuffer buffer, TensorFieldValue tensorFieldValue) {
        Tensor.Builder builder = Tensor.Builder.of(tensorFieldValue.getDataType().getTensorType());
        if (buffer.current() == JsonToken.VALUE_STRING
            && builder instanceof IndexedTensor.BoundBuilder indexedBuilder)
        {
            double[] decoded = decodeHexString(buffer.currentText(), builder.type().valueType());
            if (decoded.length == 0)
                throw new IllegalArgumentException("Bad string input for tensor with type " + builder.type());
            for (int i = 0; i < decoded.length; i++) {
                indexedBuilder.cellByDirectIndex(i, decoded[i]);
            }
            tensorFieldValue.assign(builder.build());
            return;
        }
        expectOneOf(buffer.current(), JsonToken.START_OBJECT, JsonToken.START_ARRAY);
        int initNesting = buffer.nesting();
        while (true) {
            Supplier<Token> lookahead = buffer.lookahead();
            Token next = lookahead.get();
            if (TENSOR_CELLS.equals(next.name) && ! primitiveContent(next.token, lookahead.get().token)) {
                buffer.next();
                readTensorCells(buffer, builder);
            }
            else if (TENSOR_VALUES.equals(next.name) && builder.type().dimensions().stream().allMatch(Dimension::isIndexed)) {
                buffer.next();
                readTensorValues(buffer, builder);
            }
            else if (TENSOR_BLOCKS.equals(next.name)) {
                buffer.next();
                readTensorBlocks(buffer, builder);
            }
            else if (TENSOR_TYPE.equals(next.name) && next.token == JsonToken.VALUE_STRING) {
                buffer.next();
                // Ignore input tensor type
            }
            else if (buffer.nesting() == initNesting && JsonToken.END_OBJECT == next.token) {
                buffer.next();
                break;
            }
            else {
                readDirectTensorValue(buffer, builder);
                break;
            }
        }
        expectOneOf(buffer.current(), JsonToken.END_OBJECT, JsonToken.END_ARRAY);
        tensorFieldValue.assign(builder.build());
    }
Reads the tensor format defined at
See <a href="https://docs.vespa.ai/en/reference/document-json-format.html">https://docs.vespa.ai/en/reference/document-json-format.html</a>

@author geirst
@author bratseth
document/src/main/java/com/yahoo/document/json/readers/TensorReader.java