code: def check_result(
      mod,
      ref_mod,
      map_inputs,
      out_shape,
      tol=1e-5,
      target="llvm",
      device=tvm.cpu(),
      params=None,
  ):
      if sys.platform == "win32":
          print("Skip test on Windows for now")
          return
  
      # Run the reference result
      te_compiler.get().clear()
      with tvm.transform.PassContext(opt_level=3):
          json, lib, param = relay.build(
              ref_mod, target=target, params=params
          )
      rt_mod = tvm.contrib.graph_executor.create(json, lib, device)
  
      for name, data in map_inputs.items():
          rt_mod.set_input(name, data)
      rt_mod.set_input(**param)
      rt_mod.run()
      out = tvm.nd.empty(out_shape, device=device)
      out = rt_mod.get_output(0, out)
      ref_result = out.numpy()
  
      def check_vm_result():
          te_compiler.get().clear()
          with relay.build_config(opt_level=3):
              exe = relay.vm.compile(mod, target=target, params=params)
          code, lib = exe.save()
          exe = runtime.vm.Executable.load_exec(code, lib)
          vm = runtime.vm.VirtualMachine(exe, device)
          out = vm.run(**map_inputs)
          tvm.testing.assert_allclose(
              out.numpy(), ref_result, rtol=tol, atol=tol
          )
  
      def check_graph_executor_result():
          te_compiler.get().clear()
          with relay.build_config(opt_level=3):
              json, lib, param = relay.build(
                  mod, target=target, params=params
              )
          rt_mod = tvm.contrib.graph_executor.create(json, lib, device)
  
          for name, data in map_inputs.items():
              rt_mod.set_input(name, data)
          rt_mod.set_input(**param)
          rt_mod.run()
          out = tvm.nd.empty(out_shape, device=device)
          out = rt_mod.get_output(0, out)
          tvm.testing.assert_allclose(
              out.numpy(), ref_result, rtol=tol, atol=tol
          )
  
      check_vm_result()
      check_graph_executor_result()
  
imports: import os
  import sys
  import numpy
  import tvm
  import tvm.relay.op
  import tvm.relay.testing
  from tvm import relay, runtime
  from tvm.contrib import utils
  from tvm.relay import transform
  from tvm.relay.backend import te_compiler
  from tvm.relay.build_module import bind_params_by_name
  from tvm.relay.op.contrib.register import get_pattern_table
label_desc: Use image node_id 2 for calling a global function with example usage: check_result(mod, ref_mod, map_inputs, out_shape, tol, target, device, params) without return types