code: def tune_vrmpy_auto_tensorize(mod, params, hexagon_launcher):
      """Tune VRMPY with auto tensorization."""
      sch_rules = [
          schedule_rule.ApplyCustomRule(),
          schedule_rule.AutoInline(
              into_producer=False,
              into_consumer=True,
              inline_const_tensor=True,
              disallow_if_then_else=True,
              require_injective=True,
              require_ordered=True,
              disallow_op=["tir.exp"],
          ),
          # VRMPY_u8i8i32_INTRIN is used for conv2d. See topi/hexagon/conv2d_alter_op.py
          # for why we use different intrins for conv2d and dense.
          schedule_rule.MultiLevelTilingWithIntrin(
              VRMPY_u8i8i32_INTRIN,
              structure="SRSRS",
              tile_binds=None,
              max_innermost_factor=64,
              vector_load_lens=None,
              reuse_read=None,
              reuse_write=schedule_rule.ReuseType(
                  req="may",
                  levels=[1, 2],
                  scope="global",
              ),
          ),
          # VRMPY_u8u8i32_INTRIN is used for dense
          schedule_rule.MultiLevelTilingWithIntrin(
              VRMPY_u8u8i32_INTRIN,
              structure="SRSRS",
              tile_binds=None,
              max_innermost_factor=64,
              vector_load_lens=None,
              reuse_read=None,
              reuse_write=schedule_rule.ReuseType(
                  req="may",
                  levels=[1, 2],
                  scope="global",
              ),
          ),
          schedule_rule.ParallelizeVectorizeUnroll(
              max_jobs_per_core=16,
              max_vectorize_extent=128,
              unroll_max_steps=[0, 16, 64, 512],
              unroll_explicit=True,
          ),
      ]
  
      postprocs = [
          postproc.RewriteParallelVectorizeUnroll(),
          postproc.RewriteReductionBlock(),
          postproc.RewriteTensorize(vectorize_init_loop=True),
      ]
  
      # This line is necessary for link-params to take effect during
      # task extraction and relay.build(...).
      mod = mod.with_attr("executor", EXECUTOR)
  
      num_cores = cpu_count(logical=False)
  
      with tempfile.TemporaryDirectory() as work_dir:
          database = ms.relay_integration.tune_relay(
              mod=mod,
              target=TARGET_HEXAGON,
              params=params,
              work_dir=work_dir,
              # for faster tuning
              max_trials_global=20000,
              max_trials_per_task=8,
              num_trials_per_iter=8,
              strategy="replay-trace",
              # max_trials_global=20000,
              # num_trials_per_iter=32,
              # max_trials_per_task=128,
              # strategy="evolutionary",
              builder=get_hexagon_local_builder(max_workers=num_cores),
              runner=get_hexagon_rpc_runner(
                  hexagon_launcher, number=20, max_workers=num_cores
              ),
              space=ms.space_generator.PostOrderApply(
                  sch_rules=sch_rules,
                  postprocs=postprocs,
                  mutator_probs={},
              ),
              # This enables anchor-block tuning, where different subgraphs
              # with the same anchor block workload will be identified as equal.
              # It reduces the number of conv2d tuning tasks in the int8 resnet50 model
              # from 36 to 23, with negligible performance difference.
              module_equality="anchor-block",
              num_tuning_cores=num_cores,
          )
          return ms.relay_integration.compile_relay(
              database=database,
              mod=mod,
              target=TARGET_HEXAGON,
              params=params,
          )
  
imports: import os
  import tempfile
  from types import MappingProxyType
  from typing import Any, Mapping, Optional
  import numpy
  import pytest
  import tvm
  import tvm.testing
  from tvm import meta_schedule
  from tvm import relay
  from tvm._ffi import register_func
  from tvm.contrib.hexagon.meta_schedule import get_hexagon_local_builder, get_hexagon_rpc_runner
  from tvm.meta_schedule import postproc, schedule_rule
  from tvm.meta_schedule.utils import cpu_count
  from tvm.tir.schedule import BlockRV, Schedule
  from tvm.tir.schedule.analysis import has_block
  from tvm.tir.tensor_intrin.hexagon import VRMPY_u8i8i32_INTRIN, VRMPY_u8u8i32_INTRIN, VRMPY_u8i8i32_VTCM_INTRIN
  from ..infrastructure import get_hexagon_target
label_desc: Use image node_id 2 for calling a global function with example usage: tune_vrmpy_auto_tensorize(mod, params, hexagon_launcher) and returns: ms