[JIT] Improve error message for InferredType
If we try to call `type()` on an InferredType object but the type is
null, then the assertion will fail. This adds a better error message.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/79105
Approved by: https://github.com/tugsbayasgalan