code: def run_and_check(
      func, args, var_dict={}, target="llvm", sch=None, outs=None
  ):
      def tvm_val_2_py_val(val):
          val = tvm.tir.stmt_functor.substitute(val, var_dict)
          val = tvm.arith.Analyzer().simplify(val)
          assert isinstance(val, (tvm.tir.IntImm,))
          return val.value
  
      dev = tvm.device(target, 0)
      op = None
  
      if sch is None:
          outs = func(
              *tuple(
                  tvm.runtime.convert(i) if isinstance(i, list) else i
                  for i in args
              )
          )
          op = outs[0].op if isinstance(outs, list) else outs.op
          sch = te.create_schedule(op)
      else:
          assert outs is not None
          assert isinstance(outs, list)
          op = outs[0].op
  
      emu_args = []
      nd_args = []
      for i in args:
          if isinstance(i, te.tensor.Tensor):
              shape = [tvm_val_2_py_val(j) for j in i.shape]
              emu_args.append(
                  numpy.random.randn(*shape).astype(i.dtype)
              )
              nd_args.append(tvm.nd.array(emu_args[-1], dev))
          elif isinstance(i, tvm.tir.Var):
              emu_args.append(tvm_val_2_py_val(i))
              nd_args.append(emu_args[-1])
          else:
              assert isinstance(i, list)
              emu_args.append(numpy.array(i))
  
      compile_args = [
          i
          for i in args
          if isinstance(i, (te.tensor.Tensor, tvm.tir.Var))
      ] + (outs if isinstance(outs, list) else [outs])
      module = tvm.build(sch, compile_args, target=target)
      assert module
  
      out_tensors = []
      for i in range(op.num_outputs):
          output = op.output(i)
          shape = [tvm_val_2_py_val(j) for j in output.shape]
          nd_args.append(
              tvm.nd.array(numpy.zeros(shape).astype(output.dtype), dev)
          )
          out_tensors.append(nd_args[-1])
  
      ref_data = func(*emu_args)
      if isinstance(ref_data, numpy.ndarray):
          ref_data = [ref_data]
  
      module(*nd_args)
  
      for nd, np in zip(out_tensors, ref_data):
          tvm.testing.assert_allclose(
              nd.numpy(), np, rtol=1e-5, atol=1e-5
          )
  
      module_args = [
          i
          for i in args
          if isinstance(i, (te.tensor.Tensor, tvm.tir.Var))
      ]
      module_outs = (
          [outs] if isinstance(outs, te.tensor.Tensor) else outs
      )
      h_module = te.hybrid.build(sch, module_args, module_outs)
  
      return h_module, module_args, module_outs
  
imports: import tvm, inspect, sys, traceback, numpy, pytest, types, os
  from tvm import te
  from tvm.contrib import utils
  from tvm.te.hybrid import script
  from tvm.te.hybrid.runtime import HYBRID_GLOBALS
  import tvm.testing
label_desc: Use image node_id 1 for calling a global function with example usage: run_and_check(func, args, var_dict, target, sch, outs) and returns: h_module,  module_args,  module_outs, val