If you want to use data dependent control flow in TorchScript, you need to use script mode, see the docs here 10 under “Scripting:” for details/examples.
For your model in particular it looks like it would work to add @torch.jit.script to normalize() and remove the call to torch.jit.trace.