Repository: pytorch/vision

Issue:
QuantizableMobileNetV3 Can not load pretrained model
### 🐛 Describe the bug

```python

import torchvision
quantized = torchvision.models.quantization.mobilenet_v3_large(pretrained=True)
```
It will occur
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/lib/python3.8/site-packages/torchvision/models/quantization/mobilenetv3.py", line 180, in mobilenet_v3_large
    return _mobilenet_v3_model(arch, inverted_residual_setting, last_channel, pretrained, progress, quantize, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torchvision/models/quantization/mobilenetv3.py", line 154, in _mobilenet_v3_model
    _load_weights(arch, model, model_urls.get(arch, None), progress)
  File "/opt/conda/lib/python3.8/site-packages/torchvision/models/quantization/mobilenetv3.py", line 124, in _load_weights
    model.load_state_dict(state_dict)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1482, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for QuantizableMobileNetV3:
	Unexpected key(s) in state_dict: "features.4.block.2.scale_activation.activation_post_process.scale", "features.4.block.2.scale_activation.activation_post_process.zero_point", "features.4.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.4.block.2.scale_activation.activation_post_process.observer_enabled", "features.5.block.2.scale_activation.activation_post_process.scale", "features.5.block.2.scale_activation.activation_post_process.zero_point", "features.5.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.5.block.2.scale_activation.activation_post_process.observer_enabled", "features.6.block.2.scale_activation.activation_post_process.scale", "features.6.block.2.scale_activation.activation_post_process.zero_point", "features.6.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.6.block.2.scale_activation.activation_post_process.observer_enabled", "features.11.block.2.scale_activation.activation_post_process.scale", "features.11.block.2.scale_activation.activation_post_process.zero_point", "features.11.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.11.block.2.scale_activation.activation_post_process.observer_enabled", "features.12.block.2.scale_activation.activation_post_process.scale", "features.12.block.2.scale_activation.activation_post_process.zero_point", "features.12.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.12.block.2.scale_activation.activation_post_process.observer_enabled", "features.13.block.2.scale_activation.activation_post_process.scale", "features.13.block.2.scale_activation.activation_post_process.zero_point", "features.13.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.13.block.2.scale_activation.activation_post_process.observer_enabled", "features.14.block.2.scale_activation.activation_post_process.scale", "features.14.block.2.scale_activation.activation_post_process.zero_point", "features.14.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.14.block.2.scale_activation.activation_post_process.observer_enabled", "features.15.block.2.scale_activation.activation_post_process.scale", "features.15.block.2.scale_activation.activation_post_process.zero_point", "features.15.block.2.scale_activation.activation_post_process.fake_quant_enabled", "features.15.block.2.scale_activation.activation_post_process.observer_enabled".
```

### Versions

PyTorch version: 1.10.0+cu113
Is debug build: False
CUDA used to build PyTorch: 11.3
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.1 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.19.4
Libc version: glibc-2.31

Python version: 3.8.5 (default, Sep  4 2020, 07:30:14)  [GCC 7.3.0] (64-bit runtime)
Python platform: Linux-5.4.0-90-generic-x86_64-with-glibc2.10
Is CUDA available: True
CUDA runtime version: 11.2.67
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 470.82.00
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.1.0
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.2
[pip3] pytorch-transformers==1.1.0
[pip3] torch==1.10.0+cu113
[pip3] torchaudio==0.10.0+cu113
[pip3] torchtext==0.11.0
[pip3] torchvision==0.11.1+cu113
[conda] magma-cuda110             2.5.2                         5    local
[conda] mkl                       2019.4                      243
[conda] mkl-include               2019.4                      243
[conda] nomkl                     3.0                           0
[conda] numpy                     1.19.2           py38h6163131_0
[conda] numpy-base                1.19.2           py38h75fe3a5_0
[conda] pytorch-transformers      1.1.0                    pypi_0    pypi
[conda] torch                     1.10.0+cu113             pypi_0    pypi
[conda] torchaudio                0.10.0+cu113             pypi_0    pypi
[conda] torchtext                 0.11.0                   pypi_0    pypi
[conda] torchvision               0.11.1+cu113             pypi_0    pypi


Discussion:

Resolving patch:
diff --git a/torchvision/models/quantization/mobilenetv3.py b/torchvision/models/quantization/mobilenetv3.py
--- a/torchvision/models/quantization/mobilenetv3.py
+++ b/torchvision/models/quantization/mobilenetv3.py
@@ -43,7 +43,7 @@ def _load_from_state_dict(
     ):
         version = local_metadata.get("version", None)
 
-        if version is None or version < 2:
+        if hasattr(self, "qconfig") and (version is None or version < 2):
             default_state_dict = {
                 "scale_activation.activation_post_process.scale": torch.tensor([1.0]),
                 "scale_activation.activation_post_process.zero_point": torch.tensor([0], dtype=torch.int32),


Test patch: