Add allow_rebase_history flag and fix codegen functions for multiple views (#32790)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32790
Same as https://github.com/pytorch/pytorch/pull/31990 but without the first commit in the stack that is problematic for a lot of people.
Test Plan: Imported from OSS
Differential Revision: D19814116
Pulled By: albanD
fbshipit-source-id: d104911a5b098a5807b4bc08b69803ebd4f69fa6