Keep py::object alive until jit::toIValue returns (#38348)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/38348
Test Plan: Imported from OSS
Differential Revision: D21530282
Pulled By: mrshenli
fbshipit-source-id: a507402fbbd89618936ac6eecb4a223ab86236c6