The error is raised since you are using Python classes instead of nn.Modules for the scripting.
After deriving from nn.Module this error would be gone. However, TorchScript doesn’t support inheritance as described here 23, so you might run into other issues with this approach.