code: def _build_func_common(
      measure_input, runtime=None, checks=None, build_option=None
  ):
      """Common part for building a configuration"""
      target, task, config = measure_input
      target, task.target_host = Target.canon_target_and_host(
          target, task.target_host
      )
      checks = checks or {}
      with target:
          s, args = task.instantiate(config)
  
          # check invalidity of template and code hash consistency
          if not config.valid():
              raise InstantiationError(config.errors)
  
          # if target is vta, we need to use vta build
          if (
              hasattr(measure_input.target, "device_name")
              and measure_input.target.device_name == "vta"
          ):
              # pylint: disable=import-outside-toplevel
              import vta
  
              func = vta.build(s, args, target_host=task.target_host)
          else:
              current_pass_context: tvm.ir.transform.PassContext = (
                  tvm.ir.transform.PassContext.current()
              )
              current_config = dict(current_pass_context.config)
              if build_option is not None:
                  current_config.update(build_option)
  
              if "tir.add_lower_pass" in current_config:
                  current_add_lower_pass = list(
                      current_config["tir.add_lower_pass"]
                  )
              else:
                  current_add_lower_pass = []
              if checks.get("gpu"):
                  current_add_lower_pass.append(
                      (2, gpu_verify_pass(**checks.get("gpu")))
                  )
              if checks.get("hexagon"):
                  current_add_lower_pass.append(
                      (2, vtcm_verify_pass(**checks.get("hexagon")))
                  )
              current_config[
                  "tir.add_lower_pass"
              ] = current_add_lower_pass
  
              with tvm.ir.transform.PassContext(
                  opt_level=current_pass_context.opt_level,
                  required_pass=current_pass_context.required_pass,
                  disabled_pass=current_pass_context.disabled_pass,
                  instruments=current_pass_context.instruments,
                  config=current_config,
              ):
                  func = build(s, args, target=target, runtime=runtime)
      return func, tuple(
          (get_const_tuple(x.shape), x.dtype) for x in args
      )
  
imports: import contextlib
  import logging
  import os
  import shutil
  import tempfile
  import threading
  import time
  import traceback
  import typing
  import warnings
  from collections import namedtuple
  from random import getrandbits
  import tvm._ffi
  import tvm.ir.transform
  from tvm import nd
  from tvm import rpc
  from tvm.autotvm.env import AutotvmGlobalScope, reset_global_scope
  from tvm.contrib import ndk, stackvm, tar
  from tvm.contrib.popen_pool import PopenPoolExecutor
  from tvm.driver import build
  from tvm.error import TVMError
  from tvm.target import Target
  from ..env import AutotvmGlobalScope
  from ..task.space import InstantiationError
  from ..utils import get_const_tuple
  from .measure import Builder, MeasureErrorNo, MeasureResult, Runner
label_desc: Use image node_id 1 for calling a global function with example usage: _build_func_common(measure_input, runtime, checks, build_option) and returns: func,  tuple