So x.view(batch_size, -1) is an example of the broader pattern of combining dimensions. There may be other applications, for example when you want a matrix-multiplication-like operation where the three matrix “axes” you have in vanilla matrix multiplications have different shapes. Fun fact: the very versatile einsum reduces to batch matrix multiplications. It does so using permute and view/reshape.
The other use, dual if you want, is splitting dimensions. In addition to this happing as the backward of combining dimensions this can also be useful in things like very simple downscaling (I sometimes use x.view(batch_size, c, h // 2, 2, w // 2, 2) to then do something with the dimensions of size 2 - if you take the max over both, you get a maxpool, but you could also do a logsumexp-pool or somesuch – your imagination is the limit!
Best regards
Thomas