public static Tensor toFloatTensor(IndexedTensor result, TensorType type, int nTokens) {
        if (result.shape().length != 3)
            throw new IllegalArgumentException("Expected onnx result to have 3-dimensions [batch, sequence, dim]");
        int size = type.indexedSubtype().dimensions().size();
        if (size != 1)
            throw new IllegalArgumentException("Target indexed sub-type must have one dimension");
        int wantedDimensionality = type.indexedSubtype().dimensions().get(0).size().get().intValue();
        int resultDimensionality = (int)result.shape()[2];
        if (wantedDimensionality > resultDimensionality) {
            throw new IllegalArgumentException("Not possible to map token vector embedding with " + resultDimensionality +
                                               " dimensions into tensor with " + wantedDimensionality);
        }
        Tensor.Builder builder = Tensor.Builder.of(type);
        for (int token = 0; token < nTokens; token++) {
            for (int d = 0; d < wantedDimensionality; d++) {
                var value = result.get(0,token,d); // batch, sequence token, dimension
                builder.cell(TensorAddress.of(token,d),value);
            }
        }
        return builder.build();
    }
Evaluate the embedding model if the result is not present in the context cache.

@param context the context accompanying the request
@param text the text that is embedded
@return the model output
model-integration/src/main/java/ai/vespa/embedding/ColBertEmbedder.java