private TensorType outputType(TensorType inputType) {
        var m = inputType.mappedSubtype();
        var d = function.outputType(inputType.indexedSubtype());
        if (d.mappedSubtype().rank() > 0) {
            throw new IllegalArgumentException("function used in map_subspaces type had mapped dimensions: " + d);
        }

        if (m.rank() == 0) {
            return d;
        }
        if (d.rank() == 0) {
            return TypeResolver.map(m); // decay cell type
        }
        TensorType.Value cellType = d.valueType();
        Map<String, TensorType.Dimension> dims = new HashMap<>();
        for (var dim : m.dimensions()) {
            dims.put(dim.name(), dim);
        }
        for (var dim : d.dimensions()) {
            var old = dims.put(dim.name(), dim);
            if (old != null) {
                throw new IllegalArgumentException("dimension name collision in map_subspaces: " + m + " vs " + d);
            }
        }
        return new TensorType(cellType, dims.values());
    }
The <i>map_subspaces</i> tensor function transforms each dense subspace in a (mixed) tensor

@author arnej
vespajlib/src/main/java/com/yahoo/tensor/functions/MapSubspaces.java