[quant][graphmode][refactor] Factor out common parts of general value ops (#38161)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/38161
Test Plan: Imported from OSS
Differential Revision: D21512972
fbshipit-source-id: 61425f7c51fe5972527432b74407486aa479d999