[nn] Add remove_duplicate flag to named_buffers (#674) (#85903)
Summary:
X-link: https://github.com/pytorch/torchrec/pull/674
Pull Request resolved: https://github.com/pytorch/pytorch/pull/84984
this is to allow named_buffers to return the same buffer objects with different names multiple times, needed by internal use cases
ghstack-source-id: 168589597
Test Plan:
python test/test_nn.py -k test_buffers_and_named_buffers
Imported from OSS
Reviewed By: albanD
Differential Revision: D39493161
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85903
Approved by: https://github.com/albanD