[jit] add cast<> specialization for NamedType (#35718)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35718
Because NamedType is not a concrete type (it's just an interface), it
has no corresponding TypeKind and thus no default `cast()` behavior.
Adding a specialization that does the right thing.
Test Plan: Imported from OSS
Differential Revision: D20749425
Pulled By: suo
fbshipit-source-id: 6ccab1cca26fd2b2805189fcf2305d99ae28145a