Refactor custom op tests (#31282)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31282
Introduce a helper to easily call stack ops
ghstack-source-id: 95855728
Test Plan: unit tests
Differential Revision: D19061515
fbshipit-source-id: a7d6329e26cd3d94730d88c8a6393e10bfbd8e9b