code: def tune_kernels(
      tasks,
      measure_option,
      tuner="gridsearch",
      early_stopping=None,
      log_filename="tuning.log",
  ):
      for i, task in enumerate(tasks):
          prefix = "[Task %2d/%2d] " % (i + 1, len(tasks))
  
          # create tuner
          if tuner == "xgb":
              tuner_obj = XGBTuner(task, loss_type="reg")
          elif tuner == "xgb_knob":
              tuner_obj = XGBTuner(
                  task, loss_type="reg", feature_type="knob"
              )
          elif tuner == "xgb_itervar":
              tuner_obj = XGBTuner(
                  task, loss_type="reg", feature_type="itervar"
              )
          elif tuner == "xgb_curve":
              tuner_obj = XGBTuner(
                  task, loss_type="reg", feature_type="curve"
              )
          elif tuner == "xgb_rank":
              tuner_obj = XGBTuner(task, loss_type="rank")
          elif tuner == "xgb_rank_knob":
              tuner_obj = XGBTuner(
                  task, loss_type="rank", feature_type="knob"
              )
          elif tuner == "xgb_rank_itervar":
              tuner_obj = XGBTuner(
                  task, loss_type="rank", feature_type="itervar"
              )
          elif tuner == "xgb_rank_curve":
              tuner_obj = XGBTuner(
                  task, loss_type="rank", feature_type="curve"
              )
          elif tuner == "xgb_rank_binary":
              tuner_obj = XGBTuner(task, loss_type="rank-binary")
          elif tuner == "xgb_rank_binary_knob":
              tuner_obj = XGBTuner(
                  task, loss_type="rank-binary", feature_type="knob"
              )
          elif tuner == "xgb_rank_binary_itervar":
              tuner_obj = XGBTuner(
                  task, loss_type="rank-binary", feature_type="itervar"
              )
          elif tuner == "xgb_rank_binary_curve":
              tuner_obj = XGBTuner(
                  task, loss_type="rank-binary", feature_type="curve"
              )
          elif tuner == "ga":
              tuner_obj = GATuner(task, pop_size=50)
          elif tuner == "random":
              tuner_obj = RandomTuner(task)
          elif tuner == "gridsearch":
              tuner_obj = GridSearchTuner(task)
          else:
              raise ValueError("Invalid tuner: " + tuner)
  
          # do tuning
          n_trial = len(task.config_space)
          tuner_obj.tune(
              n_trial=n_trial,
              early_stopping=early_stopping,
              measure_option=measure_option,
              callbacks=[
                  autotvm.callback.progress_bar(n_trial, prefix=prefix),
                  autotvm.callback.log_to_file(log_filename),
              ],
          )
  
file_path: tvm/gallery/how_to/tune_with_autotvm/tune_relay_x86.py
imports: import os
  import numpy
  import tvm
  from tvm import relay, autotvm
  from tvm.relay import testing
  from tvm.autotvm.tuner import XGBTuner, GATuner, RandomTuner, GridSearchTuner
  from tvm.autotvm.graph_tuner import DPTuner, PBQPTuner
  import tvm.contrib.graph_executor
label_desc: Use image node_id 2 for calling a global function with example usage: tune_kernels(tasks, measure_option, tuner, early_stopping, log_filename) without return types