I know a simple if inside a script works in the latest ONNX
@torch.jit.script
def yolo_resize_helper(net_h, net_w, im_h, im_w):
    if net_w / im_w < net_h / im_h:
        new_w = net_w
        new_h = ((im_h * net_w) / im_w).floor()
    else:
        new_h = net_h
        new_w = ((im_w * net_h) / im_h).floor()
    return new_h, new_w

But something more complicated, e.g. recursive scripts, I am trying to figure out myself.