Is scripting working for you now or are you still facing some issues?
I’m not an expert in using ONNX, but could you try to use tensors instead of Python literals via e.g.:
beam_size = torch.tensor([5])
prev_words = torch.zeros(beam_size, 1).long()