I encountered an error while trying to save the stylegan2 network as torch. onnx. export
Labels: module: onnx, triaged

### 🐛 Describe the bug

Hello, I encountered an error while trying to save the stylegan2 network as torch. onnx. export
The input for Stylgen2 is [1,512], but whether I input [1,512] or [1,1,512], I cannot obtain the correct network.

[stylegan2 address](https://github.com/rosinality/stylegan2-pytorch)
mycode

```
def to_onnx_zdim(model,onnx_name):
      dummy_input=torch.randn(1,1,512,device='cuda')
      torch.onnx.export(model,dummy_input,onnx_name,verbose=True)
```
```
sample_z = torch.randn(args.sample, args.latent, device=device) 
            sample, _ = g_ema( 
                [sample_z], truncation=args.truncation, truncation_latent=mean_latent 
            )
to_onnx_zdim(g_ema, 'output/stylegan2_net.onnx')
```

![image](https://user-images.githubusercontent.com/100210045/234238255-3defdcd1-3b72-4f3c-87a4-6c10631d60c1.png)

torch version
![image](https://user-images.githubusercontent.com/100210045/234238684-bff6cc0d-ff80-4f47-a4e4-05e48206cb90.png)


### Versions

Collecting environment information...
PyTorch version: 2.0.0+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.26.3
Libc version: glibc-2.31

Python version: 3.8.13 (default, Mar 28 2022, 11:38:47)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.14.0-1059-oem-x86_64-with-glibc2.17
Is CUDA available: True
CUDA runtime version: 11.6.55
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090

Nvidia driver version: 470.141.03
cuDNN version: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn.so.5.1.10
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
架构：                           x86_64
CPU 运行模式：                   32-bit, 64-bit
字节序：                         Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU:                             80
在线 CPU 列表：                  0-79
每个核的线程数：                 2
每个座的核数：                   20
座：                             2
NUMA 节点：                      2
厂商 ID：                        GenuineIntel
CPU 系列：                       6
型号：                           85
型号名称：                       Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHz
步进：                           7
CPU MHz：                        2100.000
CPU 最大 MHz：                   4000.0000
CPU 最小 MHz：                   800.0000
BogoMIPS：                       4200.00
虚拟化：                         VT-x
L1d 缓存：                       1.3 MiB
L1i 缓存：                       1.3 MiB
L2 缓存：                        40 MiB
L3 缓存：                        55 MiB
NUMA 节点0 CPU：                 0-19,40-59
NUMA 节点1 CPU：                 20-39,60-79
Vulnerability Itlb multihit:     KVM: Mitigation: VMX disabled
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Mitigation; TSX disabled
标记：                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rgood nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke avx512_vnni md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.23.2
[pip3] stylegan2-pytorch==1.8.9
[pip3] torch==2.0.0
[pip3] torchaudio==0.8.0
[pip3] torchsummary==1.5.1
[pip3] torchvision==0.15.1
[pip3] triton==2.0.0
[pip3] vector-quantize-pytorch==0.1.0
[conda] numpy                     1.23.2                   pypi_0    pypi
[conda] stylegan2-pytorch         1.8.9                    pypi_0    pypi
[conda] torch                     2.0.0                    pypi_0    pypi
[conda] torchaudio                0.8.0                    pypi_0    pypi
[conda] torchsummary              1.5.1                    pypi_0    pypi
[conda] torchvision               0.15.1                   pypi_0    pypi
[conda] triton                    2.0.0                    pypi_0    pypi
[conda] vector-quantize-pytorch   0.1.0                    pypi_0    pypi