code: def run_and_verify_func(
      config, target="cuda", run_module=True, data_type="float32"
  ):
      """Test a Relay func by compiling, running, and comparing TVM and TRT outputs.
  
      Parameters
      ----------
      config : Tuple[relay.Function, Dict[str, NDArray], List[str]]
          A tuple containing 1) The function to test, 2) A dictionary of var names to input shapes and
          3) A list of which vars should be considered params.
  
      run_module: bool
  
          If True, the built module will be run after being compiled.
  
      data_type: str
          Check between single and double floating precision
      """
      np.random.seed(42)
      f, input_shapes, is_param = config
      params = {
          x: np.random.uniform(-1, 1, input_shapes[x]).astype(
              dtype=data_type
          )
          for x in is_param
      }
      input_dict = {
          k: np.random.uniform(-1, 1, v).astype(dtype=data_type)
          for k, v in input_shapes.items()
          if k not in is_param
      }
      dev = tvm.device(target)
  
      result_dict = dict()
      for mode in ["vm", "graph"]:
          for use_trt in [True, False]:
              mod = tvm.IRModule()
              mod["main"] = f
              result_key = mode + ("_trt" if use_trt else "")
              if use_trt:
                  use_fp16 = data_type == "float16"
                  trt_target = tvm.target.Target(
                      f"tensorrt -use_fp16={use_fp16}"
                  )
                  mod = relay.transform.InferType()(mod)
                  mod = tensorrt.partition_for_tensorrt(
                      mod, params=params, target=trt_target
                  )
                  with tvm.transform.PassContext(opt_level=3):
                      func = relay.create_executor(
                          mode,
                          mod=mod,
                          device=dev,
                          target=[target, trt_target],
                      ).evaluate()
              else:
                  mod = relay.transform.InferType()(mod)
                  with tvm.transform.PassContext(opt_level=3):
                      func = relay.create_executor(
                          mode, mod=mod, device=dev, target=target
                      ).evaluate()
  
              if run_module:
                  result_dict[result_key] = func(**input_dict, **params)
  
              if run_module:
                  assert_result_dict_holds(result_dict, data_type)
  
imports: import itertools
  import logging
  from typing import Tuple
  import numpy
  import pytest
  import tvm
  import tvm.relay.testing
  import tvm.testing
  from tvm import relay
  from tvm.contrib.download import download
  from tvm.relay import Any, GlobalVar
  from tvm.relay.expr_functor import ExprVisitor
  from tvm.relay.op.contrib import tensorrt
label_desc: Use image node_id 5 for calling a global function with example usage: run_and_verify_func(config, target, run_module, data_type) without return types