Fix segfault while real and imaginary attributes are set to a number (#73867)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/73867
Fixes https://github.com/pytorch/pytorch/issues/72947
Test Plan: Imported from OSS
Reviewed By: davidberard98
Differential Revision: D34695956
Pulled By: anjali411
fbshipit-source-id: 2f3eda272a5214335eae506bd387ce8da4d81b8c
(cherry picked from commit fdb07354cac22c30aa047e65fbac9840608db811)