Wrap warning handler in a function to avoid siof (#30800)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30800
SparseNN benchmark crashed due to this.
Wrap warning handler in a function to avoid siof.
Test Plan: Tested locally, SparseNN benchmark no longer crashes.
Reviewed By: yinghai
Differential Revision: D18826731
fbshipit-source-id: 8fcab8a3f38cc20f775409c0686363af3c27d0a6