The contiguous() call on a tensor should be fine.
I was talking about “calling” the tensor as a method: temp_for_transpose(hidden,0,1), which would raise an error. If you want to index it, you should use temp_for_transpose[hidden,0,1].