code: def test_conditional():
      metatable = {"VirtualDevice": [CPU, GPU]}
  
      # The conditional is over a function type, thus exercising the first-order/higher-order domain handling.
      def input():
          return tvm.relay.parse(
              """
              #[version = "0.0.5"]
              def @main(%x: bool, %y: Tensor[(5, 7), float32], %z: Tensor[(5, 7), float32]) {
                let %f = fn (%a) {
                  %0 = on_device(%y, virtual_device=meta[VirtualDevice][0], constrain_result=True);
                  add(%a, %0)
                };
                let %g = fn (%a1) {
                  subtract(%a1, %y)
                };
                let %h = if (%x) {
                  %f
                } else {
                  %g
                };
                %h(%z)
              }
          """,
              "from_string",
              None,
              metatable,
          )
  
      def expected():
          return tvm.relay.parse(
              """
              #[version = "0.0.5"]
              def @main(%x {virtual_device=meta[VirtualDevice][0]}: bool, %y {virtual_device=meta[VirtualDevice][0]}: Tensor[(5, 7), float32], %z {virtual_device=meta[VirtualDevice][0]}: Tensor[(5, 7), float32],
                        virtual_device=meta[VirtualDevice][0]) {
                let %f = fn (%a {virtual_device=meta[VirtualDevice][0]}, virtual_device=meta[VirtualDevice][0]) {
                  add(%a, %y)
                };
                let %g = fn (%a1 {virtual_device=meta[VirtualDevice][0]}, virtual_device=meta[VirtualDevice][0]) {
                  subtract(%a1, %y)
                };
                let %h = on_device(if (%x) {
                  %f
                } else {
                  %g
                }, virtual_device=meta[VirtualDevice][0], constrain_result=True);
                %h(%z)
              }
          """,
              "from_string",
              None,
              metatable,
          )
  
      def ref(x, y, z):
          def f(a):
              return np.add(a, y)
  
          def g(a):
              return np.subtract(a, y)
  
          h = f if x else g
          return h(z)
  
      exercise(
          input(), expected(), ref, [True, rand((5, 7)), rand((5, 7))]
      )
  
imports: import tvm
  from tvm import relay
  from tvm.script import tir
  import tvm.testing
  import numpy
  import os
label_desc: Use image node_id 31 for calling a global function with example usage: test_conditional() and returns: tvm, tvm, h, np, np