[libtorch][torch.jit.script][input dynamic shape]Error in loading ". Pt" file on C + +: index out of range

Because it is the company’s internal code, I can’t disclose it.I can only briefly describe the phenomenon:
I’m trying to deploy a model, but its input contains dynamic dimensions: it works normally when you use the python model script to perform information on the data; After I serialize the model JIT:: script(), it will report an abnormal error, such as index out of range.
In Python mode (ptyhon code is used to directly load".cpkt" parameters for inferecne), I can inferecne normally when I load the input data without using onnx mode, and the code after loading parameters is added at the end
model=toch.jit.script(model)
model.save(“model.pt”)
An error was reported when loading the pt file even if in python code model.

If you have encountered similar situations and have relevant solutions or skills, I hope you can recover. Thank you very much!