I’m afraid it’s not implemented. Tensors doesn’t save previous shapes, as soon as you reshape it, the info about previous dimensionality is lost.
The most you can do is something like @dhpollack suggested, which would be manually saving the dimensionality.
Given a tensor T
T_flatten = T.view(*T.shape[:-2],-1)
T_unflatten = T_flatten.view(*T_flatten.shape[:-1],y,z)

As I mentioned as soon as you compute T_flatten values of y and z are lost unless you save them.
T_flatten = T.view(*T.shape[:-2],-1)
T_unflatten = T_flatten.view(*T_flatten.shape[:-1],*T.shape[-2:])

So in short if you don’t overwrite T, you can do it that way.
If you overwrite T you would need to save y and z