RuntimeError: input_shape.size() > 0 || reshape.size() > 0INTERNAL ASSERT FAILED
Labels: needs reproduction, module: onnx, triaged, onnx-needs-info

### 🐛 Describe the bug

I am getting this error when I try to convert a PyTorch Model to ONNX. 

```
/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/__init__.py:676: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  assert condition, message
/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/timm/models/vision_transformer.py:201: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
/home/ashishpapanai/Desktop/MAVI_Text/parseq/strhub/models/parseq/system.py:129: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if testing and (tgt_in == self.eos_id).any(dim=-1).all():
/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py:716: UserWarning: allowzero=0 by default. In order to honor zero value in shape use allowzero=1
  warnings.warn("allowzero=0 by default. In order to honor zero value in shape use allowzero=1")
/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py:325: UserWarning: Type cannot be inferred, which might cause exported graph to produce incorrect results.
  warnings.warn("Type cannot be inferred, which might cause exported graph to produce incorrect results.")
Traceback (most recent call last):
  File "demo_read.py", line 96, in <module>
    main()
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "demo_read.py", line 71, in main
    verbose = True)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/__init__.py", line 320, in export
    custom_opsets, enable_onnx_checker, use_external_data_format)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/utils.py", line 111, in export
    custom_opsets=custom_opsets, use_external_data_format=use_external_data_format)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/utils.py", line 729, in _export
    dynamic_axes=dynamic_axes)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/utils.py", line 501, in _model_to_graph
    module=module)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/utils.py", line 216, in _optimize_graph
    graph = torch._C._jit_pass_onnx(graph, operator_export_type)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/__init__.py", line 373, in _run_symbolic_function
    return utils._run_symbolic_function(*args, **kwargs)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/utils.py", line 1032, in _run_symbolic_function
    return symbolic_fn(g, *inputs, **attrs)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/symbolic_opset9.py", line 568, in view
    return reshape(g, self, size)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/symbolic_opset9.py", line 76, in reshape
    return sym_help._reshape_helper(g, self, shape)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py", line 717, in _reshape_helper
    return g.op("Reshape", input, shape, allowzero_i=allowzero)
  File "/home/ashishpapanai/miniconda3/envs/parseq/lib/python3.7/site-packages/torch/onnx/utils.py", line 928, in _graph_op
    torch._C._jit_pass_onnx_node_shape_type_inference(n, _params_dict, opset_version)
RuntimeError: input_shape.size() > 0 || reshape.size() > 0INTERNAL ASSERT FAILED at "../torch/csrc/jit/passes/onnx/shape_type_inference.cpp":448, please report a bug to PyTorch. Reshape node should have at least one input size > 0 when constant folding.

```

## Converting: ParSeq (https://github.com/baudm/parseq)
### Code used for conversion
```
model1 = load_from_checkpoint(args.checkpoint, **kwargs).eval().to(args.device)
    img_transform1 = SceneTextDataModule.get_transform(model1.hparams.img_size)

 #   model2 = load_from_checkpoint(args.hi_checkpoint, **kwargs).eval().to(args.device)
 #   img_transform2 = SceneTextDataModule.get_transform(model2.hparams.img_size)

    img_dir = args.image_dir[0]
    folder_list = os.listdir(img_dir)
    #dummy_input = torch.rand(1, 3, 32, 128) 
    
    

    for folder in folder_list:
        img_list = os.listdir(os.path.join(img_dir,folder))
        ptr = open('read_output/'+folder+'.txt', 'w')
        #print(folder)
        for fname in img_list:
            # Load image and prepare for input
            image = Image.open(os.path.join(img_dir,folder,fname)).convert('RGB')
            image1 = img_transform1(image).unsqueeze(0).to(args.device)
            #model1.to_onnx('parseq.onnx', input, opset_version=14)  
            #return "Done"
            #english
            
            torch.onnx.export(model1, 
                        image1, 
                        'ParSeq.onnx', 
                        export_params=True, 
                        opset_version=14,
                        do_constant_folding=True,
                        input_names=['input'],
                        output_names=['output'],
                        verbose = True)
```

### Versions

```
Collecting environment information...
PyTorch version: 1.10.2+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
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.23.2
Libc version: glibc-2.17

Python version: 3.7.13 (default, Mar 29 2022, 02:18:16)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.13.0-44-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce MX250
Nvidia driver version: 470.129.06
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] botorch==0.6.4
[pip3] gpytorch==1.8.1
[pip3] numpy==1.21.6
[pip3] pytorch-lightning==1.6.5
[pip3] torch==1.10.2
[pip3] torchmetrics==0.9.3
[pip3] torchvision==0.11.3
[conda] botorch                   0.6.4                    pypi_0    pypi
[conda] gpytorch                  1.8.1                    pypi_0    pypi
[conda] numpy                     1.21.6                   pypi_0    pypi
[conda] pytorch-lightning         1.6.5                    pypi_0    pypi
[conda] torch                     1.10.2                   pypi_0    pypi
[conda] torchmetrics              0.9.3                    pypi_0    pypi
[conda] torchvision               0.11.3                   pypi_0    pypi
```