Explicitly export submodules and variables from torch module (#52339)
Summary:
For https://github.com/pytorch/pytorch/issues/47027.
Some progress has been made in https://github.com/pytorch/pytorch/issues/50665, but in my testing trying to unwrap the circular dependencies is turning into a neverending quest.
This PR explicitly exports things in the top-level torch module without any semantic effect, in accordance with this py.typed library guidance: https://github.com/microsoft/pyright/blob/master/docs/typed-libraries.md#library-interface
It may be possible to do some of the other fixes just using `__all__` where needed, but `__all__` has a semantic effect I would like to further review. This PR at least fixes simple completions like `torch.nn` in Pylance/pyright.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52339
Reviewed By: smessmer
Differential Revision: D26694909
Pulled By: malfet
fbshipit-source-id: 99f2c6d0bf972afd4036df988e3acae857dde3e1