Replace the view operations with input = input.view(input.size(0), your_shapes or -1) to keep the batch size equal.
If this approach raises shape mismatches in e.g. linear layers, adapt the in_features to the expected values.