Make assertions refine types (#23949)
Summary:
Make assertions like `x is not None` refine the type of x. This is easy to do now that typing understands [exits](https://github.com/pytorch/pytorch/pull/23565).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/23949
Differential Revision: D16692772
Pulled By: eellison
fbshipit-source-id: 540f28e65a784c72c7c555e0aed0765d5035bc37