Torch.jit isuue with submodules(Resnet)

I created a model that uses two Resnets(pre-trained) as feature extractors
In my model I used a pre-trained Resnet as a sub module.

Training and testing work well in pytorch, but
If you use simple torch.jit.trace while converting torch, the following error occurs.

could not export python function call Scatter. Remove calls to Python functions before export. Did you forget add @script or @script_method annotation? If this is a nn.ModuleList, add it to constants .:

if i want to use sub_module, it looks like i need to use trace and script together, as shown in the code below from the official pytorch homepage.
##################################

import torch
import torchvision
class MyScriptModule(torch.nn.Module):
def init(self):
super(MyScriptModule, self).init()
self.means = torch.nn.Parameter(torch.tensor([103.939, 116.779, 123.68])
.resize_(1, 3, 1, 1))
self.resnet = torch.jit.trace(torchvision.models.resnet18(),
torch.rand(1, 3, 224, 224))
def forward(self, input):
return self.resnet(input - self.means)
my_script_module = torch.jit.script(MyScriptModule())

########################################################

but, This also causes an error.

Please advise if this approach is correct or if you can make a simple trace.

plzā€¦

The code snippet from the website you posted works fine for me (on PyTorch 1.2, are you up to date?), can you post a full code example that results in the could not export Python function.. error?