code: def test_kws_autotune_workflow(platform, board, tmp_path):
      mod, params = fetch_model_from_url(
          url="https://github.com/tensorflow/tflite-micro/raw/a56087ffa2703b4d5632f024a8a4c899815c31bb/tensorflow/lite/micro/examples/micro_speech/micro_speech.tflite",
          model_format="tflite",
          sha256="09e5e2a9dfb2d8ed78802bf18ce297bff54281a66ca18e0c23d69ca14f822a83",
      )
      target = tvm.micro.testing.get_target(platform, board)
  
      str_io_logs = tvm.micro.testing.tune_model(
          platform, board, target, mod, params, TUNING_RUNS_PER_OPERATOR
      )
      assert isinstance(str_io_logs, StringIO)
  
      str_logs = str_io_logs.getvalue().rstrip().split("\n")
      logs = list(map(json.loads, str_logs))
  
      # Some tuning tasks don't have any config space, and will only be run once
      with tvm.transform.PassContext(
          opt_level=3, config={"tir.disable_vectorize": True}
      ):
          tasks = tvm.autotvm.task.extract_from_program(
              mod["main"], {}, target
          )
      assert (
          len(tasks)
          <= len(logs)
          <= len(tasks) * TUNING_RUNS_PER_OPERATOR
      )
  
      # Check we tested both operators
      op_names = list(map(lambda x: x["input"][1], logs))
      assert (
          op_names[0]
          == op_names[1]
          == "conv2d_nhwc_spatial_pack.arm_cpu"
      )
  
      # Make sure we tested different code. != does deep comparison in Python 3
      assert logs[0]["config"]["index"] != logs[1]["config"]["index"]
      assert logs[0]["config"]["entity"] != logs[1]["config"]["entity"]
  
      # Compile the best model with AOT and connect to it
      str_io_logs.seek(0)
      with tvm.micro.testing.create_aot_session(
          platform,
          board,
          target,
          mod,
          params,
          build_dir=tmp_path,
          tune_logs=str_io_logs,
      ) as session:
          aot_executor = tvm.runtime.executor.aot_executor.AotModule(
              session.create_aot_executor()
          )
  
          samples = (
              np.random.randint(
                  low=-127, high=128, size=(1, 1960), dtype=np.int8
              )
              for x in range(3)
          )
  
          # Validate perforance across random runs
          runtimes = [
              runtime
              for _, runtime in tvm.micro.testing.predict_labels_aot(
                  session, aot_executor, samples, runs_per_sample=20
              )
          ]
          # `time` is the average time taken to execute model inference on the
          # device, measured in seconds. It does not include the time to upload
          # the input data via RPC. On slow boards like the Arduino Due, time
          # is around 0.12 (120 ms), so this gives us plenty of buffer.
          assert np.median(runtimes) < 1
  
file_path: tvm/tests/micro/common/test_autotune.py
imports: from io import StringIO
  import json
  import numpy
  import pytest
  import tvm
  import tvm.testing
  import tvm.micro.testing
  from tvm.testing.utils import fetch_model_from_url
label_desc: Use image node_id 1 for calling a global function with example usage: test_kws_autotune_workflow(platform, board, tmp_path) without return types