@Test
    @SuppressWarnings("OptionalGetWithoutIsPresent")
    public void testArrayEmbedTo2MappedTensor() {
        var tester = new EmbeddingScriptTester(Map.of("emb1", new EmbeddingScriptTester.MockMappedEmbedder("myDocument.my2DSparseTensor")));

        TensorType tensorType = TensorType.fromSpec("tensor(passage{}, token{})");
        var expression = tester.expressionFrom("input myTextArray | embed emb1 passage | attribute 'my2DSparseTensor'");
        assertEquals("input myTextArray | embed emb1 passage | attribute my2DSparseTensor", expression.toString());

        SimpleTestAdapter adapter = new SimpleTestAdapter();
        adapter.createField(new Field("myTextArray", new ArrayDataType(DataType.STRING)));
        var tensorField = new Field("my2DSparseTensor", new TensorDataType(tensorType));
        adapter.createField(tensorField);

        var array = new Array<StringFieldValue>(new ArrayDataType(DataType.STRING));
        array.add(new StringFieldValue("abc"));
        array.add(new StringFieldValue("cde"));
        adapter.setValue("myTextArray", array);
        expression.setStatementOutput(new DocumentType("myDocument"), tensorField);

        expression.resolve(new TypeContext(adapter));

        ExecutionContext context = new ExecutionContext(adapter);
        context.setCurrentValue(array);
        expression.execute(context);
        assertTrue(adapter.values.containsKey("my2DSparseTensor"));
        var sparse2DTensor = (TensorFieldValue) adapter.values.get("my2DSparseTensor");
        assertEquals(Tensor.from(
                             tensorType,
                             "tensor(passage{},token{}):" +
                             "{{passage:0,token:97}:97.0, " +
                             "{passage:0,token:98}:98.0, " +
                             "{passage:0,token:99}:99.0, " +
                             "{passage:1,token:100}:100.0, " +
                             "{passage:1,token:101}:101.0, " +
                             "{passage:1,token:99}:99.0}"),
                     sparse2DTensor.getTensor().get());
    }
Multiple paragraphs with sparse encoding (splade style)
indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/EmbeddingScriptTestCase.java