I've got a n x n x 2 matrix which I want to find all possible permutations of without changing the order of elements in the 3rd dimension.
For example, if my matrix was 2 x 2 x 2 and had the following values:
[[[1,2], [3,4]],
[5,6], [7,8]]
Then possible permutations would be:
[[[1,2], [3,4]],
[7,8], [5,6]]
[[[3,4], [1,2]],
[5,6], [7,8]]
[[[1,2], [7,8]],
[5,6], [3,4]]
etc.
In other words, I want to treat the tuples as single values when finding the permutations.