[1.8] Add additional tests for object-based APIs (#51341)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51341
Adds tests for objects that contain CPU/GPU tensors to ensure that
they can also be serialized/deserialized appropriately.
ghstack-source-id: 120718120
Test Plan: CI
Reviewed By: SciPioneer
Differential Revision: D26144100
fbshipit-source-id: f1a8ccb9741bb5372cb7809cb43cbe43bf47d517