replace permutedims