function axesAreInnerMostDims(axes, rank) {
    for(let i = 0; i < axes.length; ++i){
        if (axes[axes.length - i - 1] !== rank - 1 - i) return false;
    }
    return true;
}
Returns the axes permutation that undoes the original permutation.