code: def tune_and_evaluate():
      print("Begin tuning...")
      tuner = auto_scheduler.TaskScheduler(tasks, task_weights)
      tune_option = auto_scheduler.TuningOptions(
          num_measure_trials=200,  # change this to 20000 to achieve the best performance
          builder=auto_scheduler.LocalBuilder(
              build_func="ndk" if use_ndk else "default"
          ),
          runner=auto_scheduler.RPCRunner(
              device_key,
              host="127.0.0.1",
              port=9190,
              repeat=3,
              timeout=50,
          ),
          measure_callbacks=[auto_scheduler.RecordToFile(log_file)],
      )
  
      tuner.tune(tune_option)
  
      # Compile the whole network
      print("Compile...")
      with auto_scheduler.ApplyHistoryBest(log_file):
          with tvm.transform.PassContext(
              opt_level=3,
              config={"relay.backend.use_auto_scheduler": True},
          ):
              lib = relay.build(mod, target, params=params)
  
      # Create graph executor
      print("=============== Request Remote ===============")
      from tvm.auto_scheduler.utils import request_remote
  
      remote = request_remote(device_key, "127.0.0.1", 9190)
      dev = remote.cl()
      from tvm.contrib import utils, ndk
  
      temp = utils.tempdir()
      filename = "deploy_lib.so"
      path_lib = temp.relpath(filename)
      lib.export_library(path_lib, fcompile=ndk.create_shared)
      remote.upload(path_lib)
      loaded_lib = remote.load_module(filename)
      module = graph_executor.GraphModule(loaded_lib["default"](dev))
      data = (np.random.uniform(size=input_shape)).astype(dtype)
      data_tvm = tvm.nd.array(data)
      module.set_input("data", data_tvm)
  
      # Evaluate
      print("Evaluate inference time cost...")
      print(module.benchmark(dev, repeat=3, min_repeat_ms=500))
  
file_path: tvm/gallery/how_to/tune_with_autoscheduler/tune_network_mali.py
imports: import numpy
  import tvm
  from tvm import relay, auto_scheduler
  import tvm.relay.testing
  from tvm.contrib import graph_executor
  import os
label_desc: Use image node_id 2 for calling a global function with example usage: tune_and_evaluate() without return types