public long toDirectIndex(int index) {
        if (dimensions.size() == 0) {
            return 0;
        }
        if (dimensionMap == null)  {
            throw new IllegalArgumentException("Dimension map is not available");
        }
        long directIndex = 0;
        long rest = index;
        for (int i = 0; i < dimensions.size(); ++i) {
            long address = rest / innerSizesOriginal[i];
            directIndex += innerSizesVespa[dimensionMap[i]] * address;
            rest %= innerSizesOriginal[i];
        }
        return directIndex;
    }
When dimension ordering between Vespa and imported differs, i.e.
after dimension renaming, use the dimension map to read in values
so that they are correctly laid out in memory for Vespa.
Used when importing tensors.
model-integration/src/main/java/ai/vespa/rankingexpression/importer/OrderedTensorType.java