Improve wrapper subclass detection for serialization (#81105)
Fixes https://github.com/pytorch/pytorch/issues/80983
Also fix a small bug uncovered by the new test where creating memory_view for 0-sized inputs is not valid and is now skipped
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81105
Approved by: https://github.com/ezyang