Hi,
Let’s go in steps:
lstm.py:72: TracerWarning: Converting a tensor to a Python list 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!
  cap_lens = cap_lens.data.tolist()

This warning indicates that you are converting a tensor to a list, and you can’t backpropagate through python values, only Tensors. You can fix this error by removing the .tolist() in that line (it’s not necessary).
This will also fix the other warning just below.
The other errors that you had happen because of Dropout nodes, which are non-deterministic. By default, we check the traces that were generated by computing it twice and seeing if the result has changed (which might imply that there are control flows in your code that should be torch.jit.script instead).
In your case, as you only have a `dropout, I’d say that you could disable the check, by doing the following:
traced_script_module = torch.jit.trace(model, (captions, cap_lens, hidden), check_trace=False)

I believe those two points should fix all your issues. You can inspect the generated trace via traced_script_module.graph.