code: def check_result(
      mod,
      map_inputs,
      out_shape,
      result,
      tol=1e-5,
      target="llvm",
      device=tvm.cpu(),
      params=None,
  ):
      if sys.platform == "win32":
          print("Skip test on Windows for now")
          return
  
      def update_lib(lib):
          test_dir = os.path.dirname(
              os.path.realpath(os.path.expanduser(__file__))
          )
          source_dir = os.path.join(test_dir, "..", "..", "..")
          contrib_path = os.path.join(
              source_dir, "src", "runtime", "contrib"
          )
  
          kwargs = {}
          kwargs["options"] = ["-O2", "-std=c++17", "-I" + contrib_path]
          tmp_path = utils.tempdir()
          lib_name = "lib.so"
          lib_path = tmp_path.relpath(lib_name)
          lib.export_library(lib_path, fcompile=False, **kwargs)
          lib = runtime.load_module(lib_path)
  
          return lib
  
      def check_vm_result():
          with tvm.transform.PassContext(
              opt_level=3, disabled_pass=["AlterOpLayout"]
          ):
              exe = relay.vm.compile(mod, target=target, params=params)
          code, lib = exe.save()
          lib = update_lib(lib)
          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(), result, rtol=tol, atol=tol
          )
  
      def check_graph_executor_result():
          with tvm.transform.PassContext(
              opt_level=3, disabled_pass=["AlterOpLayout"]
          ):
              json, lib, param = relay.build(
                  mod, target=target, params=params
              )
          lib = update_lib(lib)
          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(), result, rtol=tol, atol=tol
          )
  
      check_vm_result()
      check_graph_executor_result()
  
imports: import os
  import sys
  import numpy
  import pytest
  import tvm
  import tvm.relay.testing
  import tvm.relay.transform
  from tvm import relay
  from tvm import runtime
  from tvm.contrib import utils
label_desc: Use image node_id 1 for calling a global function with example usage: check_result(mod, map_inputs, out_shape, result, tol, target, device, params) and returns: lib