code: def tune_conv2d_template(
      mod,
      scheduler,
      schedule_tag,
      params,
      hexagon_launcher,
      pass_config: Mapping[str, Any] = MappingProxyType({}),
  ):
      """Generate packed 8*8*32 template."""
  
      def schedule_rule_conv2d(sch: Schedule, conv2d_block: BlockRV):
          scheduler()(sch, conv2d_block)
          return [sch]
  
      register_func(
          "meta_schedule.conv2d_NCHWc_int8.{}.hexagon".format(
              schedule_tag
          ),
          schedule_rule_conv2d,
      )
  
      def schedule_conv2d_for_tune(sch: Schedule):
          scheduler()(sch)
  
      # This line is necessary for link-params to take effect during
      # task extraction and relay.build(...).
      mod = mod.with_attr("executor", EXECUTOR)
  
      pass_context = None
      if len(pass_config.items()) > 0:
          pass_context = (
              tvm.transform.PassContext(opt_level=3, config=pass_config)
              if pass_config is not None
              else None
          )
  
      with tempfile.TemporaryDirectory() as work_dir:
          database = ms.relay_integration.tune_relay(
              mod=mod,
              target=TARGET_HEXAGON,
              params=params,
              work_dir=work_dir,
              max_trials_global=20000,
              max_trials_per_task=1,
              num_trials_per_iter=1,
              strategy="replay-trace",
              builder=get_hexagon_local_builder(pass_context),
              runner=get_hexagon_rpc_runner(hexagon_launcher, number=1),
              # Apply MS auto scheduling rules for all blocks, but utilize
              # the custom block scheduling strategy registered above for
              # blocks annotated as `schedule_rule:meta_schedule.conv2d_NCHWc_int8`
              # space=ms.space_generator.PostOrderApply(
              #     f_block_filter=None,
              #     sch_rules="from-target",
              #     postprocs=[],
              #     mutator_probs="from-target",
              # ),
              # Constrain search space to only be the single
              # schedule provided for all blocks. No auto
              # scheduling will be possible.
              space=ms.space_generator.ScheduleFn(
                  schedule_conv2d_for_tune,
                  sch_rules=[],
                  postprocs=[],
                  mutator_probs={},
              ),
              # Without this, the same workloads with different constant weights
              # are treated as distinct tuning tasks.
              module_equality="ignore-ndarray",
          )
  
          # Add default options so that it still uses the base config.
          pass_config["relay.backend.use_meta_schedule"] = True
          pass_config["relay.backend.tir_converter"] = "default"
          return ms.relay_integration.compile_relay(
              database=database,
              mod=mod,
              target=TARGET_HEXAGON,
              params=params,
              pass_config=pass_config,
          )
  
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 6 for calling a global function with example usage: tune_conv2d_template(mod, scheduler, schedule_tag, params, hexagon_launcher, pass_config) and returns: list, ms