Add initial support for serializing classes
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/22953
Test Plan: Imported from OSS
Reviewed By: suo
Differential Revision: D16340214
Pulled By: zdevito
fbshipit-source-id: 70fb1968eca34e14492e0d2be52e28b27813f821