functionalization: map copy_() -> to().expand_as() (#67878)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/67878
The functionalization pass doesn't work with `copy_()` which is a problem with functorch. Originally we were going to make a functional `copy()` operator to fix this problem, but zou3519 that we can get (most of) the existing functionality by mapping `self.copy_(src)` to `src.to(self).expand_as(self)`. This makes the codegen a bit uglier, but has the benefit of avoiding a totally unnecessary tensor allocation in functorch.
Test Plan: Imported from OSS
Reviewed By: zou3519
Differential Revision: D32280588
Pulled By: bdhirsh
fbshipit-source-id: 2c6ee65f0929e0846566987183ba2498c88496c2