avoid multiple writes to files on export (#21186)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/21186
ghimport-source-id: 2f62fed50e0d74f4162b74b6a2f44b8baa376316
Differential Revision: D15581527
Pulled By: suo
fbshipit-source-id: b1150cfa47d8df6f217f048c742a5ba9fa7f7935