code: def test_fold_let_with_on_device():
      """Make sure on_device annotations don't get in the way of constant folding,
      and inlined constants bring their annotations with them."""
      c_data = np.array(1).astype("float32")
      t = relay.TensorType([1], "float32")
  
      def before():
          sb = relay.ScopeBuilder()
          x = relay.var("x", t)
          x.virtual_device_ = tvm.cpu()
          t1 = sb.let("t1", annot_expr(relay.const(c_data)))
          t2 = sb.let("t2", annot_expr(relay.add(t1, t1)))
          t3 = sb.let("t3", annot_expr(relay.add(t2, x)))
          sb.ret(t3)
          f = relay.Function([x], sb.get())
          f.virtual_device_ = tvm.cpu()
          return f
  
      def expected():
          sb = relay.ScopeBuilder()
          x = relay.var("x", t)
          x.virtual_device_ = tvm.cpu()
          c_folded = c_data + c_data
          t3 = sb.let(
              "t3",
              annot_expr(
                  relay.add(annot_expr(relay.const(c_folded)), x)
              ),
          )
          sb.ret(t3)
          f = relay.Function([x], sb.get())
          f.virtual_device_ = tvm.cpu()
          return f
  
      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 7 for calling a global function with example usage: test_fold_let_with_on_device() and returns: f, f