Repository: pytorch
Issue: [Tracer] RuntimeError: _Map_base::at when tracing fake quantization
Labels: oncall: jit

### 🐛 Describe the bug

RuntimeError was thrown from this sample code.

```python
import torch

class M(torch.nn.Module):
    def __init__(self) -> None:
        super().__init__()
        self.quant = torch.quantization.QuantStub()
        self.linear = torch.nn.Linear(4, 3)
        self.dequant = torch.quantization.DeQuantStub()

    def forward(self, x):
        x = self.quant(x)
        x = self.linear(x)
        x = self.dequant(x)
        return x

model_fp32 = M()
model_fp32.qconfig = torch.quantization.get_default_qconfig("fbgemm")
model_fp32_qat = torch.quantization.prepare_qat(model_fp32)

input_fp32 = torch.randn(8, 4)
model_fp32_qat.eval()

# forward works
print(model_fp32_qat(input_fp32))

# tracing fails
torch.jit.trace(model_fp32_qat, input_fp32)
```

Further analysis shows the root cause is from tracing https://github.com/pytorch/pytorch/blob/09f32eba7a29e8a61a6ad1506b4097e8237b28bf/torch/ao/quantization/observer.py#L1120, when `combined_min.shape` is empty. A shorter repro below

```python
import torch

class M(torch.nn.Module):
    def forward(self, x, y):
        x = x.resize_(y.shape)
        return x, y

x = torch.tensor(1.2)

M()(x, x)
torch.jit.trace(M(), (x, x))
```

```
Traceback (most recent call last):
  File "repro_trace_empty_tuple.py", line 11, in <module>
    torch.jit.trace(M(), (x, x))
  File "/home/bowbao/pytorch/torch/jit/_trace.py", line 750, in trace
    _module_class,
  File "/home/bowbao/pytorch/torch/jit/_trace.py", line 965, in trace_module
    argument_names,
  File "/home/bowbao/pytorch/torch/nn/modules/module.py", line 1129, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/bowbao/pytorch/torch/nn/modules/module.py", line 1117, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "repro_trace_empty_tuple.py", line 5, in forward
    x = x.resize_(y.shape)
RuntimeError: _Map_base::at
```

### Versions

Collecting environment information...
PyTorch version: 1.12.0a0+git15e0836
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.3 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: 10.0.0-4ubuntu1
CMake version: version 3.22.2
Libc version: glibc-2.17

Python version: 3.7.11 (default, Jul 27 2021, 14:32:16)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.13.0-28-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: False
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1080
Nvidia driver version: 510.47.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.3.2
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] mypy==0.812
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.6
[pip3] pytorch-sphinx-theme==0.0.24
[pip3] torch==1.12.0a0+git15e0836
[pip3] torchaudio==0.10.2
[pip3] torchdynamo==0.2.0
[pip3] torchmetrics==0.7.3
[pip3] torchvision==0.13.0a0+78c24bb
[conda] mkl                       2022.0.1           h06a4308_117
[conda] mkl-include               2022.0.1           h06a4308_117
[conda] mypy                      0.812                    pypi_0    pypi
[conda] mypy-extensions           0.4.3                    pypi_0    pypi
[conda] numpy                     1.21.6                   pypi_0    pypi
[conda] pytorch-sphinx-theme      0.0.24                    dev_0    <develop>
[conda] torch                     1.12.0a0+git15e0836           dev_0    <develop>
[conda] torchaudio                0.10.2                   pypi_0    pypi
[conda] torchdynamo               0.2.0                     dev_0    <develop>
[conda] torchmetrics              0.7.3                    pypi_0    pypi
[conda] torchvision               0.12.0a0+5b82590          pypi_0    pypi