clone should preserve the type of attribute (#29269)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29269
Hit this bug when I have an attribute of type `Optional[Tensor]` which
is initialized to None and reassigned later to some tensor.
Test Plan:
.
Imported from OSS
Differential Revision: D18364338
fbshipit-source-id: d8e1277a84ab7d80331cba83f5639469d398632e