The trace works when I use:
traced_module_rpn = torch.jit.trace(model.rpn_model, [ Variable(z), Variable(x) ] )

but with this warning:
rpn.py:18: TracerWarning: Converting a tensor to a Python integer 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!
  po = F.conv2d(px, pk, groups=batch)

where line 18: of rpn.py is
    po = F.conv2d(px, pk, groups=batch)

Any help in understanding this warning message is highly appreciated.