[ONNX][bug] `nn.Transformer` contains unsupported tensor scalar type
Labels: module: onnx, triaged, onnx-triaged, bug

### 🐛 Describe the bug

PyTorch fails to export a model containing an `nn.Transformer` module. It fails with `RuntimeError: unexpected tensor scalar type`. Here's a minimal repro script:

```python
import torch
import torch.nn as nn


class M(nn.Module):
  def __init__(self):
    super().__init__()
    self.transformer = nn.Transformer(d_model=128)

  def forward(self, x, y):
    return self.transformer(x, y)


module = M()
module = torch.jit.script(module)
x = torch.randn([10, 1, 128])
y = torch.randn([10, 1, 128])
dummy_input = (x, y)
torch.onnx.export(module, dummy_input, 'test.onnx', verbose=True, opset_version=14)
```

### Versions

```
Collecting environment information...
PyTorch version: 1.12.1+cu113
Is debug build: False
CUDA used to build PyTorch: 11.3
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: version 3.19.6
Libc version: glibc-2.27

Python version: 3.9.12 (main, Apr  5 2022, 06:56:58)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-4.15.0-118-generic-x86_64-with-glibc2.27
Is CUDA available: True
CUDA runtime version: 11.3.58
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce GTX 1080 Ti
GPU 2: NVIDIA GeForce RTX 3090

Nvidia driver version: 465.19.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.5.1
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.1.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.22.4
[pip3] pytest-mypy==0.9.1
[pip3] torch==1.12.1+cu113
[pip3] torch-tb-profiler==0.3.1
[pip3] torch-tensorrt==1.1.0
[pip3] torchtext==0.11.0a0+d697db5
[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] magma-cuda112             2.5.2                         1    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-include               2021.3.0           h06a4308_520  
[conda] numpy                     1.22.4                   pypi_0    pypi
[conda] torch                     1.12.1+cu113             pypi_0    pypi
[conda] torch-tb-profiler         0.3.1                    pypi_0    pypi
[conda] torch-tensorrt            1.1.0                    pypi_0    pypi
[conda] torchtext                 0.11.0a0+d697db5          pypi_0    pypi
```