Reshape tensor while keeping data in a given dimension

I do not think you can do this as tensor.unfold depending on some criteria creates another dimension like .unsqueeze(0) and because of that .view and .permute will no longer be valid due to number of dimension mismatch.

Actually, I have never thought of generalizing fold and unfold method due to its tricky behavior (or at least my bad understanding).