Repository: pytorch
Issue: Graph Mode Quantization does not keep NamedTuple Information
Labels: oncall: quantization,low priority,triaged,module: fx

### 🐛 Describe the bug

After preparing a module for quantization, it looks like we somehow are discarding `NamedTuple` information for any `preserved_attributes` we have. For instance, if I run this script:

```python
from typing import NamedTuple

import torch
from torch import nn
from torch.quantization.qconfig import get_default_qconfig
from torch.quantization.quantize_fx import prepare_fx


class A(NamedTuple):
    x: int
    y: str


class B(nn.Module):
    def __init__(self):
        super().__init__()
        self.a = A(1, "a")

    @torch.jit.export
    def other_method(self):
        return self.a.x

    def forward(self, inputs: torch.Tensor):
        return inputs + 1


module = B().eval()

prepared = prepare_fx(
    module,
    {"": get_default_qconfig("qnnpack")},
    prepare_custom_config_dict={"preserved_attributes": ["other_method", "a"]},
)
torch.jit.script(prepared)
```

I get the following error:
```python
Traceback (most recent call last):
  File "repro.py", line 34, in <module>
    torch.jit.script(prepared)
  File "/home/alandu/miniconda3/envs/ctrldev/lib/python3.8/site-packages/torch/jit/_script.py", line 1257, in script
    return torch.jit._recursive.create_script_module(
  File "/home/alandu/miniconda3/envs/ctrldev/lib/python3.8/site-packages/torch/jit/_recursive.py", line 451, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/home/alandu/miniconda3/envs/ctrldev/lib/python3.8/site-packages/torch/jit/_recursive.py", line 517, in create_script_module_impl
    create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
  File "/home/alandu/miniconda3/envs/ctrldev/lib/python3.8/site-packages/torch/jit/_recursive.py", line 368, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
RuntimeError: 
'Tuple[int, str]' object has no attribute or method 'x'.:
  File "repro.py", line 21
    @torch.jit.export
    def other_method(self):
        return self.a.x
               ~~~~~~~~ <--- HERE
```

It seems the `NamedTuple`-ness of `self.a` is lost and it's being treated as just a normal tuple. This is weird, because `prepared.a` returns a NamedTuple as expected.

### Versions

```
PyTorch version: 1.10.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Fedora release 34 (Thirty Four) (x86_64)
GCC version: (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1)
Clang version: 12.0.1 (Fedora 12.0.1-1.fc34)
CMake version: Could not collect
Libc version: glibc-2.33

Python version: 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 23:21:18)  [GCC 9.3.0] (64-bit runtime)
Python platform: Linux-5.15.12-100.fc34.x86_64-x86_64-with-glibc2.10
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[conda] blas                      2.112                       mkl    conda-forge
[conda] blas-devel                3.9.0            12_linux64_mkl    conda-forge
[conda] cpuonly                   1.0                           0    pytorch
[conda] libblas                   3.9.0            12_linux64_mkl    conda-forge
[conda] libcblas                  3.9.0            12_linux64_mkl    conda-forge
[conda] liblapack                 3.9.0            12_linux64_mkl    conda-forge
[conda] liblapacke                3.9.0            12_linux64_mkl    conda-forge
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-devel                 2021.4.0           ha770c72_730    conda-forge
[conda] mkl-include               2021.4.0           h8d4b97c_729    conda-forge
[conda] mypy                      0.782                      py_0    conda-forge
[conda] mypy_extensions           0.4.3            py38h578d9bd_4    conda-forge
[conda] numpy                     1.20.3           py38h9894fe3_1    conda-forge
[conda] pytorch                   1.10.1              py3.8_cpu_0    pytorch
[conda] pytorch-mutex             1.0                         cpu    pytorch
```

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel @ezyang @SherlockNoMad @EikanWang @wenzhe-nrv