You can use permute to order the dimensions as you wany (which is a rotation of the tensor)
the view function reorder picking first elements in the outer dimensions like
if u have a 5d tensor
it will keep this order
[5,4,3,2,1]
applied to you case
you have to do
x_bar = model(x)  # model is an CNN auto-encoder, for example
x_bar = x_bar.view(batch_size , n_chunk, 1, input_size_1, input_size_2 ).permute(0,2,3,1).view(batch_size , n_chunk, 1, input_size_1,-1)

Look at permute cos i didnt paid attention to the exact order