code: def test_fold_if():
      cond_data = np.array(1).astype("bool")
      x_data = np.array([[1, 2, 3]]).astype("float32")
  
      def before():
          a = relay.const(cond_data)
          x = relay.const(x_data)
          y = relay.const(x_data)
          iff = relay.If(a, x + y, x - y)
          return relay.Function([], iff)
  
      def expected():
          y_data = x_data + x_data
          y = relay.const(y_data)
          return relay.Function([], y)
  
      zz = run_opt_pass(before(), transform.FoldConstant())
      zexpected = run_opt_pass(expected(), transform.InferType())
      tvm.ir.assert_structural_equal(zz, zexpected)
  
      cond_data = np.array(0).astype("bool")
  
      def before():
          a = relay.const(cond_data)
          x = relay.const(x_data)
          y = relay.const(x_data)
          iff = relay.If(a, x + y, x - y)
          return relay.Function([], iff)
  
      def expected():
          y_data = x_data - x_data
          y = relay.const(y_data)
          return relay.Function([], y)
  
      zz = run_opt_pass(before(), transform.FoldConstant())
      zexpected = run_opt_pass(expected(), transform.InferType())
      tvm.ir.assert_structural_equal(zz, zexpected)
  
imports: import numpy
  import tvm
  import tvm.testing
  from tvm import relay
  from tvm.relay.backend import Executor
  from tvm.relay import transform
  from tvm.relay.build_module import bind_params_by_name
  from tvm.relay.testing import run_infer_type, create_workload
label_desc: Use image node_id 10 for calling a global function with example usage: test_fold_if() and returns: relay, relay, relay, relay