You cannot use relay.build(...) to build a model with control flow. For that, you need to use VM.
relay.build(...)
See for example,
https://github.com/apache/incubator-tvm/blob/efe3a79aacd934ea5ffb13170230bf199a473e72/tests/python/frontend/pytorch/test_forward.py#L1914