Repository: open-mmlab/mmdeploy (language: python)

Issue:
[Bug] RuntimeError: NYI: Named tensors are not supported with the tracer
### Checklist

- [X] I have searched related issues but cannot get the expected help.
- [X] 2. I have read the [FAQ documentation](https://github.com/open-mmlab/mmdeploy/blob/master/docs/en/faq.md) but cannot get the expected help.
- [X] 3. The bug has not been fixed in the latest version.

### Describe the bug

when i run tools/deploy.py to deploy mmocr abinet, report a error  RuntimeError: NYI: Named tensors are not supported with the tracer

### Reproduction

python tools/deploy.py configs/mmocr/text-recognition/text-recognition_tensorrt_static-32x128.py E:/code/mmocr-1.0.0rc5/configs/textrecog/abinet/abinet_20e_st-an_mj.py E:\code\test\abinet_20e_st-an_mj_20221005_012617-ead8c139.pth E:\code\test\crop_0.jpg

### Environment

```Shell
02/08 10:09:21 - mmengine - INFO - **********Environmental information**********
02/08 10:09:25 - mmengine - INFO - sys.platform: win32
02/08 10:09:25 - mmengine - INFO - Python: 3.8.16 (default, Jan 17 2023, 22:25:28) [MSC v.1916 64 bit (AMD64)]
02/08 10:09:25 - mmengine - INFO - CUDA available: True
02/08 10:09:25 - mmengine - INFO - numpy_random_seed: 2147483648
02/08 10:09:25 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 3090
02/08 10:09:25 - mmengine - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3
02/08 10:09:25 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.3, V11.3.109
02/08 10:09:25 - mmengine - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30147 版
02/08 10:09:25 - mmengine - INFO - GCC: n/a
02/08 10:09:25 - mmengine - INFO - PyTorch: 1.12.1+cu113
02/08 10:09:25 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - C++ Version: 199711
  - MSVC 192829337
  - Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - OpenMP 2019
  - LAPACK is enabled (usually provided by MKL)
  - CPU capability usage: AVX2
  - CUDA Runtime 11.3
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
  - CuDNN 8.3.2  (built against CUDA 11.5)
  - Magma 2.5.4
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.3.2, CXX_COMPILER=C:/actions-runner/_work/pytorch/pytorch/builder/windows/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -IC:/actions-runner/_work/pytorch/pytorch/builder/windows/mkl/include -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.12.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,

02/08 10:09:25 - mmengine - INFO - TorchVision: 0.13.1+cu113
02/08 10:09:25 - mmengine - INFO - OpenCV: 4.7.0
02/08 10:09:25 - mmengine - INFO - MMEngine: 0.5.0
02/08 10:09:25 - mmengine - INFO - MMCV: 2.0.0rc3
02/08 10:09:25 - mmengine - INFO - MMCV Compiler: MSVC 192829924
02/08 10:09:25 - mmengine - INFO - MMCV CUDA Compiler: 11.3
02/08 10:09:25 - mmengine - INFO - MMDeploy: 1.0.0rc1+unknown
02/08 10:09:25 - mmengine - INFO -

02/08 10:09:25 - mmengine - INFO - **********Backend information**********
02/08 10:09:25 - mmengine - INFO - tensorrt:    8.4.0.6
02/08 10:09:25 - mmengine - INFO - tensorrt custom ops: Available
02/08 10:09:25 - mmengine - INFO - ONNXRuntime: None
02/08 10:09:25 - mmengine - INFO - ONNXRuntime-gpu:     1.12.1
02/08 10:09:25 - mmengine - INFO - ONNXRuntime custom ops:      Available
02/08 10:09:25 - mmengine - INFO - pplnn:       None
02/08 10:09:25 - mmengine - INFO - ncnn:        None
02/08 10:09:25 - mmengine - INFO - snpe:        None
02/08 10:09:25 - mmengine - INFO - openvino:    None
02/08 10:09:25 - mmengine - INFO - torchscript: 1.12.1+cu113
02/08 10:09:25 - mmengine - INFO - torchscript custom ops:      NotAvailable
02/08 10:09:25 - mmengine - INFO - rknn-toolkit:        None
02/08 10:09:25 - mmengine - INFO - rknn-toolkit2:       None
02/08 10:09:25 - mmengine - INFO - ascend:      None
02/08 10:09:25 - mmengine - INFO - coreml:      None
02/08 10:09:25 - mmengine - INFO - tvm: None
02/08 10:09:25 - mmengine - INFO -

02/08 10:09:25 - mmengine - INFO - **********Codebase information**********
02/08 10:09:25 - mmengine - INFO - mmdet:       3.0.0rc5
02/08 10:09:25 - mmengine - INFO - mmseg:       1.0.0rc3
02/08 10:09:25 - mmengine - INFO - mmcls:       1.0.0rc5
02/08 10:09:25 - mmengine - INFO - mmocr:       1.0.0rc5
02/08 10:09:25 - mmengine - INFO - mmedit:      None
02/08 10:09:25 - mmengine - INFO - mmdet3d:     None
02/08 10:09:25 - mmengine - INFO - mmpose:      None
02/08 10:09:25 - mmengine - INFO - mmrotate:    None
02/08 10:09:25 - mmengine - INFO - mmaction:    None
```


### Error traceback

```Shell
Traceback (most recent call last):
  File "D:\anaconda3\envs\mmcv\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "D:\anaconda3\envs\mmcv\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\core\pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\pytorch2onnx.py", line 98, in torch2onnx
    export(
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\core\pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\core\pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\core\pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\core\pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\onnx\export.py", line 131, in export
    torch.onnx.export(
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\onnx\__init__.py", line 350, in export
    return utils.export(
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\onnx\utils.py", line 163, in export
    _export(
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\onnx\utils.py", line 1074, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\onnx\optimizer.py", line 11, in model_to_graph__custom_optimizer
    graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\onnx\utils.py", line 727, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\onnx\utils.py", line 602, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\onnx\utils.py", line 517, in _trace_and_get_graph_from_model
    trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\jit\_trace.py", line 1175, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\jit\_trace.py", line 127, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\jit\_trace.py", line 118, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1118, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\onnx\export.py", line 123, in wrapper
    return forward(*arg, **kwargs)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\codebase\mmocr\models\text_recognition\encoder_decoder_recognizer.py", line 36, in encoder_decoder_recognizer__forward 
    return self.decoder.predict(feat, out_enc, data_samples)
  File "e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\codebase\mmocr\models\text_recognition\base_decoder.py", line 29, in base_decoder__forward
    out_dec = self(feat, out_enc, data_samples)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1118, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmocr\models\textrecog\decoders\base.py", line 166, in forward
    return self.forward_test(feat, out_enc, data_samples)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmocr\models\textrecog\decoders\abi_fuser.py", line 145, in forward_test
    raw_result = self.forward_train(feat, logits, data_samples)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmocr\models\textrecog\decoders\abi_fuser.py", line 114, in forward_train
    out_dec = self.language_decoder(feat, text_logits,
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1118, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmocr\models\textrecog\decoders\base.py", line 166, in forward
    return self.forward_test(feat, out_enc, data_samples)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmocr\models\textrecog\decoders\abi_language_decoder.py", line 180, in forward_test
    return self.forward_train(feat, logits, data_samples)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmocr\models\textrecog\decoders\abi_language_decoder.py", line 146, in forward_train
    output = m(
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\nn\modules\module.py", line 1118, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmcv\cnn\bricks\transformer.py", line 809, in forward
    attn_masks = [
  File "D:\anaconda3\envs\mmcv\lib\site-packages\mmcv\cnn\bricks\transformer.py", line 810, in <listcomp>
    copy.deepcopy(attn_masks) for _ in range(self.num_attn)
  File "D:\anaconda3\envs\mmcv\lib\copy.py", line 153, in deepcopy
    y = copier(memo)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\_tensor.py", line 110, in __deepcopy__
    new_storage = self.storage().__deepcopy__(memo)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\storage.py", line 569, in __deepcopy__
    return self._new_wrapped_storage(copy.deepcopy(self._storage, memo))
  File "D:\anaconda3\envs\mmcv\lib\copy.py", line 153, in deepcopy
    y = copier(memo)
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\storage.py", line 89, in __deepcopy__
    new_storage = self.clone()
  File "D:\anaconda3\envs\mmcv\lib\site-packages\torch\storage.py", line 103, in clone
    return type(self)(self.nbytes(), device=self.device).copy_(self)
RuntimeError: NYI: Named tensors are not supported with the tracer
02/08 10:15:58 - mmengine - ERROR - e:\dnntrain\environment\mmdeploy-dev-1.x\mmdeploy\apis\core\pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.
```

[Bug]  ABINet to ONNX/tensorrt failed
### Checklist

- [X] I have searched related issues but cannot get the expected help.
- [X] 2. I have read the [FAQ documentation](https://github.com/open-mmlab/mmdeploy/tree/main/docs/en/faq.md) but cannot get the expected help.
- [X] 3. The bug has not been fixed in the latest version.

### Describe the bug

Attempted to convert abinet model to onnx and tensorrt using tools/deploy.py failed.

### Reproduction

1. mim download mmocr --config abinet_20e_st-an_mj --dest ./abinet
2. convert model
    2-1. convert to onnx 
```
           python tools/deploy.py \
              /home/project/mmdeploy/configs/mmocr/text-recognition/text-recognition_onnxruntime_static.py \
              downloads/abinet/abinet_20e_st-an_mj.py \
              downloads/abinet/abinet_20e_st-an_mj_20221005_012617-ead8c139.pth \
              demo/resources/text_recog.jpg \
              --work-dir downloads/abinet/onnx \
              --device cpu \
              --dump-info

```    
    2-2. convert to tensorrt
```
          python tools/deploy.py \
              /home/project/mmdeploy/configs/mmocr/text-recognition/text-recognition_tensorrt_static-32x128.py \
              downloads/abinet/abinet_20e_st-an_mj.py \
              downloads/abinet/abinet_20e_st-an_mj_20221005_012617-ead8c139.pth \
              demo/resources/text_recog.jpg \
              --work-dir downloads/abinet/trt \
              --device cuda \
              --dump-info

```

### Environment

```Shell
08/01 08:40:09 - mmengine - INFO - 

08/01 08:40:09 - mmengine - INFO - **********Environmental information**********
08/01 08:40:10 - mmengine - INFO - sys.platform: linux
08/01 08:40:10 - mmengine - INFO - Python: 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
08/01 08:40:10 - mmengine - INFO - CUDA available: True
08/01 08:40:10 - mmengine - INFO - numpy_random_seed: 2147483648
08/01 08:40:10 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4080
08/01 08:40:10 - mmengine - INFO - CUDA_HOME: /usr/local/cuda
08/01 08:40:10 - mmengine - INFO - NVCC: Cuda compilation tools, release 12.0, V12.0.140
08/01 08:40:10 - mmengine - INFO - GCC: x86_64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
08/01 08:40:10 - mmengine - INFO - PyTorch: 1.14.0a0+44dac51
08/01 08:40:10 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 9.4
  - C++ Version: 201402
  - Intel(R) oneAPI Math Kernel Library Version 2021.1-Product Build 20201104 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.7.0 (Git Hash N/A)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: NO AVX
  - CUDA Runtime 12.0
  - NVCC architecture flags: -gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90;-gencode;arch=compute_90,code=compute_90
  - CuDNN 8.7  (built against CUDA 11.8)
  - Magma 2.6.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.0, CUDNN_VERSION=8.7.0, CXX_COMPILER=/usr/bin/c++, CXX_FLAGS=-fno-gnu-unique -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=1.14.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=ON, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

08/01 08:40:10 - mmengine - INFO - TorchVision: 0.15.0a0
08/01 08:40:10 - mmengine - INFO - OpenCV: 4.7.0
08/01 08:40:10 - mmengine - INFO - MMEngine: 0.7.4
08/01 08:40:10 - mmengine - INFO - MMCV: 2.0.1
08/01 08:40:10 - mmengine - INFO - MMCV Compiler: GCC 9.4
08/01 08:40:10 - mmengine - INFO - MMCV CUDA Compiler: 12.0
08/01 08:40:10 - mmengine - INFO - MMDeploy: 1.1.0+
08/01 08:40:10 - mmengine - INFO - 

08/01 08:40:10 - mmengine - INFO - **********Backend information**********
08/01 08:40:10 - mmengine - INFO - tensorrt:    8.5.3.1
08/01 08:40:10 - mmengine - INFO - tensorrt custom ops: NotAvailable
08/01 08:40:10 - mmengine - INFO - ONNXRuntime: 1.15.1
08/01 08:40:10 - mmengine - INFO - ONNXRuntime-gpu:     1.15.1
08/01 08:40:10 - mmengine - INFO - ONNXRuntime custom ops:      NotAvailable
08/01 08:40:10 - mmengine - INFO - pplnn:       None
08/01 08:40:10 - mmengine - INFO - ncnn:        None
08/01 08:40:10 - mmengine - INFO - snpe:        None
08/01 08:40:10 - mmengine - INFO - openvino:    None
08/01 08:40:10 - mmengine - INFO - torchscript: 1.14.0a0+44dac51
08/01 08:40:10 - mmengine - INFO - torchscript custom ops:      NotAvailable
08/01 08:40:10 - mmengine - INFO - rknn-toolkit:        None
08/01 08:40:10 - mmengine - INFO - rknn-toolkit2:       None
08/01 08:40:10 - mmengine - INFO - ascend:      None
08/01 08:40:10 - mmengine - INFO - coreml:      None
08/01 08:40:10 - mmengine - INFO - tvm: None
08/01 08:40:10 - mmengine - INFO - vacc:        None
08/01 08:40:10 - mmengine - INFO - 

08/01 08:40:10 - mmengine - INFO - **********Codebase information**********
08/01 08:40:10 - mmengine - INFO - mmdet:       3.0.0
08/01 08:40:10 - mmengine - INFO - mmseg:       None
08/01 08:40:10 - mmengine - INFO - mmpretrain:  None
08/01 08:40:10 - mmengine - INFO - mmocr:       1.0.1
08/01 08:40:10 - mmengine - INFO - mmagic:      None
08/01 08:40:10 - mmengine - INFO - mmdet3d:     None
08/01 08:40:10 - mmengine - INFO - mmpose:      None
08/01 08:40:10 - mmengine - INFO - mmrotate:    None
08/01 08:40:10 - mmengine - INFO - mmaction:    None
08/01 08:40:10 - mmengine - INFO - mmrazor:     None
```


### Error traceback

```Shell
2-1. convert to onnx 

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/pytorch2onnx.py", line 98, in torch2onnx
    export(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 131, in export
    torch.onnx.export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 506, in export
    _export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1533, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/optimizer.py", line 27, in model_to_graph__custom_optimizer
    graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1113, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 989, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 893, in _trace_and_get_graph_from_model
    trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 1260, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 127, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 118, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 123, in wrapper
    return forward(*arg, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/codebase/mmocr/models/text_recognition/encoder_decoder_recognizer.py", line 36, in encoder_decoder_recognizer__forward
    return self.decoder.predict(feat, out_enc, data_samples)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/codebase/mmocr/models/text_recognition/base_decoder.py", line 29, in base_decoder__forward
    out_dec = self(feat, out_enc, data_samples)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/base.py", line 166, in forward
    return self.forward_test(feat, out_enc, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_fuser.py", line 145, in forward_test
    raw_result = self.forward_train(feat, logits, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_fuser.py", line 114, in forward_train
    out_dec = self.language_decoder(feat, text_logits,
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/base.py", line 166, in forward
    return self.forward_test(feat, out_enc, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_language_decoder.py", line 180, in forward_test
    return self.forward_train(feat, logits, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_language_decoder.py", line 146, in forward_train
    output = m(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 816, in forward
    attn_masks = [
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 817, in <listcomp>
    copy.deepcopy(attn_masks) for _ in range(self.num_attn)
  File "/usr/lib/python3.8/copy.py", line 153, in deepcopy
    y = copier(memo)
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 119, in __deepcopy__
    new_storage = self._typed_storage()._deepcopy(memo)
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 660, in _deepcopy
    return self._new_wrapped_storage(copy.deepcopy(self._untyped_storage, memo))
  File "/usr/lib/python3.8/copy.py", line 153, in deepcopy
    y = copier(memo)
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 98, in __deepcopy__
    new_storage = self.clone()
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 112, in clone
    return type(self)(self.nbytes(), device=self.device).copy_(self)
RuntimeError: NYI: Named tensors are not supported with the tracer
08/01 08:40:53 - mmengine - ERROR - /usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.


2-2. convert to tensorrt

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/pytorch2onnx.py", line 98, in torch2onnx
    export(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 131, in export
    torch.onnx.export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 506, in export
    _export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1533, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/optimizer.py", line 27, in model_to_graph__custom_optimizer
    graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1113, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 989, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 893, in _trace_and_get_graph_from_model
    trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 1260, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 127, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 118, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 123, in wrapper
    return forward(*arg, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/codebase/mmocr/models/text_recognition/encoder_decoder_recognizer.py", line 35, in encoder_decoder_recognizer__forward
    out_enc = self.encoder(feat, data_samples)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmocr/mmocr/models/textrecog/encoders/abi_encoder.py", line 81, in forward
    feature = m(feature)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 830, in forward
    query = self.attentions[attn_index](
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmengine/utils/misc.py", line 395, in new_func
    output = old_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 542, in forward
    out = self.attn(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/activation.py", line 1164, in forward
    attn_output, attn_output_weights = F.multi_head_attention_forward(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py", line 5186, in multi_head_attention_forward
    attn_output, attn_output_weights = _scaled_dot_product_attention(
TypeError: _scaled_dot_product_attention__tensorrt() takes from 3 to 5 positional arguments but 7 were given
08/01 08:43:42 - mmengine - ERROR - /usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.
```



Discussion / hints:
Could not reproduce the error with MMCV 2.0.0rc3, MMDet v1.0.0rc5 and MMOCR 1.0.0rc3. Would it be the platform problem? I used Ubuntu 18.04.
same error in ubuntu 20.04 


Fix patch:
diff --git a/mmdeploy/pytorch/functions/__init__.py b/mmdeploy/pytorch/functions/__init__.py
index 19515408af..ba40970b3d 100644
--- a/mmdeploy/pytorch/functions/__init__.py
+++ b/mmdeploy/pytorch/functions/__init__.py
@@ -5,6 +5,7 @@
 from . import cat  # noqa: F401,F403
 from . import chunk  # noqa: F401,F403
 from . import clip  # noqa: F401,F403
+from . import copy  # noqa: F401,F403
 from . import expand  # noqa: F401,F403
 from . import flatten  # noqa: F401,F403
 from . import getattribute  # noqa: F401,F403
diff --git a/mmdeploy/pytorch/functions/copy.py b/mmdeploy/pytorch/functions/copy.py
new file mode 100644
index 0000000000..1d3cf9b190
--- /dev/null
+++ b/mmdeploy/pytorch/functions/copy.py
@@ -0,0 +1,17 @@
+# Copyright (c) OpenMMLab. All rights reserved.
+from torch import Tensor
+
+from mmdeploy.core import FUNCTION_REWRITER
+
+
+@FUNCTION_REWRITER.register_rewriter(func_name='copy.deepcopy')
+def copy__default(tensor: Tensor, *args, **kwargs) -> Tensor:
+    """Rewrite `copy.deepcopy` for default backend.
+
+    Replace it with tensor.clone(), or may raise `NYI: Named tensors are not
+    supported with the tracer`
+    """
+    ctx = FUNCTION_REWRITER.get_context()
+    if isinstance(tensor, Tensor) and args == () and kwargs == {}:
+        return tensor.clone()
+    return ctx.origin_func(tensor, *args, **kwargs)


Test patch:
diff --git a/tests/test_pytorch/test_pytorch_functions.py b/tests/test_pytorch/test_pytorch_functions.py
index f0313915ef..50481ac436 100644
--- a/tests/test_pytorch/test_pytorch_functions.py
+++ b/tests/test_pytorch/test_pytorch_functions.py
@@ -667,3 +667,23 @@ def test_cat__tensorrt(dtype, dynamic_axes):
         rewrite_output[0].cpu().float(),
         rtol=1e-3,
         atol=1e-5)
+
+
+@backend_checker(Backend.TENSORRT)
+def test_copy__default():
+    import copy
+    input = torch.rand(2, 4)
+    model = WrapFunction(
+        lambda input: [copy.deepcopy(input) for i in range(3)])
+    pytorch_output = model(input)
+    rewrite_output, _ = get_rewrite_outputs(
+        model,
+        model_inputs={'input': input},
+        deploy_cfg=get_trt_config(['output'], shape=[2, 4], dynamic_axes=None),
+        run_with_backend=True)
+    for pytorch_out, rewrite_out in zip(pytorch_output, rewrite_output):
+        assert torch.allclose(
+            pytorch_out.cpu().float(),
+            rewrite_out.cpu().float(),
+            rtol=1e-3,
+            atol=1e-5)