Refactor pickler (#19035)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19035
ghimport-source-id: 553977b9963d4877e5066a61702f887e81706598
Differential Revision: D14839341
Pulled By: driazati
fbshipit-source-id: d6e4f21b2df28e2a0a21b26bf08d9905599119ad