MultiMarginCriterion: move scalar_check from codegen to code.
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/30827
Test Plan: Imported from OSS
Differential Revision: D18833658
Pulled By: gchanan
fbshipit-source-id: decd42789d92d4fbfeea9b470b3d7333e3862263