[JIT] Fix classes as attributes in recursive scripting
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/32594
Test Plan: Imported from OSS
Differential Revision: D19562951
Pulled By: jamesr66a
fbshipit-source-id: 3d5491c1c23456f107390a78be16da687de951e6