code: def tune_and_test(
      relay_mod,
      data_np,
      weight_np,
      op_name,
      target,
      sch_rules,
      postprocs,
  ):
      """Test tuning."""
      tgt = "cuda" if "nvidia" in target else target
      dev = tvm.device(tgt, 0)
      ref = (
          relay.create_executor(
              "vm", mod=relay_mod, device=dev, target=tgt
          )
          .evaluate()(*[data_np, weight_np])
          .numpy()
      )
      params = {"weight": weight_np}
      tune_tasks = list(
          filter(
              lambda task: op_name in task.task_name,
              ms.relay_integration.extract_tasks(
                  relay_mod, target, params
              ),
          )
      )
      with tempfile.TemporaryDirectory() as work_dir:
          (
              tasks,
              task_weights,
          ) = ms.relay_integration.extracted_tasks_to_tune_contexts(
              extracted_tasks=tune_tasks,
              work_dir=work_dir,
              space=ms.space_generator.PostOrderApply(
                  sch_rules=sch_rules,
                  postprocs=postprocs,
              ),
          )
          database = ms.tune.tune_tasks(
              tasks=tasks,
              task_weights=task_weights,
              work_dir=work_dir,
              max_trials_global=32,
          )
      with database, tvm.transform.PassContext(
          opt_level=3,
          config={"relay.backend.use_meta_schedule": True},
      ):
          lib = relay.build(relay_mod, target=target, params=params)
  
      if "cascadelake" in target:
          asm = lib.lib.get_source("asm")
          assert "vpdpbusd" in asm
  
      if "skylake-avx512" in target:
          asm = lib.lib.get_source("asm")
          assert "pmaddubs" in asm
          assert "pmaddw" in asm
  
      runtime = tvm.contrib.graph_executor.GraphModule(
          lib["default"](dev)
      )
      runtime.set_input("data", data_np)
      runtime.run()
      out = runtime.get_output(0).numpy()
      np.testing.assert_equal(out, ref)
  
imports: import tempfile
  import numpy
  import pytest
  import tvm
  import tvm.testing
  import tvm.topi.testing
  from tvm import meta_schedule
  from tvm import relay
  from tvm.meta_schedule.testing import relay_workload
  from tvm.meta_schedule.testing.tlcbench import load_quantized_bert_base
  from tvm.tir.tensor_intrin.arm_cpu import DP4A_INTRIN
  from tvm.tir.tensor_intrin.rocm import AMDGPU_SDOT4_INTRIN
  from tvm.tir.tensor_intrin.x86 import VNNI_DOT_16x4_INTRIN
  from tvm.tir.tensor_intrin.x86 import AVX512_DOT_16x4_INTRIN
label_desc: Use image node_id 3 for calling a global function with example usage: tune_and_test(relay_mod, data_np, weight_np, op_name, target, sch_rules, postprocs) without return types