private Tensor embed(String s, TensorType type, Embedder.Context embedderContext, Map<String, String> contextValues,
                         Properties properties) {
        if ( ! s.endsWith(")"))
            throw new IllegalArgumentException("Expected any string enclosed in embed(), but the argument does not end by ')'");
        String argument = s.substring("embed(".length(), s.length() - 1);
        Embedder embedder;
        String embedderId;

        // Check if arguments specifies an embedder with the format embed(embedder, "text to encode")
        Matcher matcher;
        if (( matcher = embedderArgumentAndQuotedTextRegexp.matcher(argument)).matches()) {
            embedderId = matcher.group(1);
            embedder = requireEmbedder(embedderId);
            argument = matcher.group(2);
        } else if (( matcher = embedderArgumentAndReferenceRegexp.matcher(argument)).matches()) {
                embedderId = matcher.group(1);
                embedder = requireEmbedder(embedderId);
                argument = matcher.group(2);
        } else if (embedders.isEmpty()) {
            throw new IllegalArgumentException("No embedders provided");  // should never happen
        } else if (embedders.size() > 1) {
            String usage = "Usage: embed(embedder-id, 'text'). " + embedderIds(embedders);
            if (! argument.contains("\"") && ! argument.contains("'"))
                throw new IllegalArgumentException("Multiple embedders are provided but the string to embed is not quoted. " + usage);
            else
                throw new IllegalArgumentException("Multiple embedders are provided but no embedder id is given. " + usage);
        } else {
            var entry = embedders.entrySet().stream().findFirst().get();
            embedderId = entry.getKey();
            embedder = entry.getValue();
        }
        return embedder.embed(resolve(argument, contextValues, properties), embedderContext.copy().setEmbedderId(embedderId), type);
    }
A class which knows how to convert an Object value to a tensor of a given type.

@author bratseth
container-search/src/main/java/com/yahoo/search/schema/internal/TensorConverter.java