Simplify reshape and fix _refs.unflatten (#83827)
Unflatten was incorrectly calling into `reshape` rather than `view`.
When looking at the checks performed in `reshape`, I saw that the
in PrimTorch is quite divergent from that in PyTorch, to the point that
it took me some time to be able to prove that they were equivalent.
I refactored that part into a separate function, and I implemented the
logic that we have in ATen, together with the same errors.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83827
Approved by: https://github.com/ngimel