code: def _lower(mod, target, params, opt_level=3):
      """Helper to lower VTA properly."""
      # pylint: disable=import-outside-toplevel
      from tvm import relay
      from tvm.relay.backend import graph_executor_codegen
  
      if hasattr(target, "device_name") and target.device_name == "vta":
          import vta
  
          with vta.build_config(
              opt_level=opt_level, disabled_pass={"AlterOpLayout"}
          ):
              mod, _ = relay.optimize(mod, target=target, params=params)
              grc = graph_executor_codegen.GraphExecutorCodegen(
                  None, target
              )
              grc.codegen(mod, mod["main"])
              return
  
      # Alter op layout code has been written expecting that tuning is applied
      # without it, so we disable AlterOpLayout to maintain that behavior.
      with tvm.transform.PassContext(
          opt_level=opt_level, disabled_pass={"AlterOpLayout"}
      ):
          compiler = relay.vm.VMCompiler()
          if params:
              compiler.set_params(params)
          compiler.lower(mod, target=target)
  
file_path: tvm/python/tvm/autotvm/task/relay_integration.py
imports: import threading
  import logging
  import tvm
  from tvm.autotvm.task.dispatcher import DispatchContext, FallbackContext
  from tvm.target import Target
  from .task import create
  from .topi_integration import TaskExtractEnv
label_desc: Use image node_id 1 for calling a global function with example usage: _lower(mod, target, params, opt_level) without return types