[JIT] optimize_for_inference on methods other than forward (#69367)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/69367
Test Plan: Imported from OSS
Reviewed By: cpuhrsch
Differential Revision: D32835529
Pulled By: davidberard98
fbshipit-source-id: d3066c23d071bc2a3bee59b8ab03b6ab0e43efcf