ComputesY = g(X) = transpose_rightmost_dims(X, rightmost_perm)
Y = g(X) = transpose_rightmost_dims(X, rightmost_perm)
Useful links