def matrix_transpose(matrix):
 return matrix.swapaxes((-2), (-1))

def matrix_transpose ( matrix ) : return matrix . swapaxes ( ( - 2 ) , ( - 1 ) )
transpose a matrix or stack of matrices by swapping the last two axes .