Export NamedTuple when it's nested in first type layer Dict (#75996)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/75996
Nested NamedTuple is supported when loading the model. However one case is missing when exporting the model. if it's the first layer, we haven't covered the `Dict` type yet.
Before:
```
// ty is a generic type pointer and can be any type
for (const TypePtr& ty : mobile_code.types_) {
std::string type_str = get_type_str(t);
if (t is TupleType) do B
}
```
After:
```
for (const TypePtr& ty : mobile_code.types_) {
std::string type_str = get_type_str(t);
if (t is DictType) do A
else if (t is TupleType) do B
}
```
ghstack-source-id: 154292348
Test Plan:
Use the uploaded model from Everstore: `GBE5xgh6J6T0ZfsAAAhQ7n_pxB90br0LAAAP`. Get it by `clowder get GBE5xgh6J6T0ZfsAAAhQ7n_pxB90br0LAAAP namedtuple.ptl`.
```
TEST(LiteInterpreterTest, DebugDper) {
std::string path =
"/data/sandcastle/boxes/fbsource/fbcode/caffe2/test/cpp/jit/namedtuple.ptl";
// mobile::Module bc = _load_for_mobile(path);
Module jit_m = load(path);
std::string resave_path =
"/data/sandcastle/boxes/fbsource/fbcode/caffe2/test/cpp/jit/namedtuple_reave.ptl";
jit_m._save_for_mobile(resave_path);
mobile::Module bc = _load_for_mobile(resave_path);
}
```
```
buck test //caffe2/test/cpp/jit:jit -- --exact 'caffe2/test/cpp/jit:jit - LiteInterpreterTest.DebugDper'
buck test mode/opt-split-dwarf //dper3/dper3/modules/tests:id_score_list_to_id_list_test
```
Reviewed By: iseeyuan
Differential Revision: D35705480
fbshipit-source-id: b8da2e720b8ca247bb40f13b67b75b5a04709f7a
(cherry picked from commit 73bb6f9ddbefcd7e55e8660a9b55ae6b9eb9759c)