How to ensure that all rows or columns are shifted while shuffling the tensor？
Representing a shuffling via indices or via a binary matrix are equivalent. In both cases you may have instances that are mapped back to themselves: either by having 1's on the diagonal of the binary matrix or by shuffled indices that equal their relative position.
Now I need to randomize an existing tensor of m*m and make sure all rows or columns will not stay in the original position, the shuffle() function provided by python can only achieve the randomization function, but can not guarantee that all elements are moved. Alternatively, a diagonal matrix can be randomly disordered to ensure that there are no zeros on the diagonal and that element 1 appears only once in each row and column, and multiplying this matrix with the original matrix will also achieve the above function, but how to generate such a matrix is also a problem. If anyone knows how to solve this problem, please reply to me, I would be very grateful!