code: def test_apply_history_best_multiple_batches(tmpdir):
      tsk, target = get_sample_task()
      best = str(tsk.config_space.get(2))
  
      inputs_batch_1 = [
          MeasureInput(target, tsk, tsk.config_space.get(i))
          for i in range(2)
      ]
      results_batch_1 = [
          MeasureResult((i,), 0, 0, 0) for i in range(1, 3)
      ]
      filepath_batch_1 = tmpdir / "batch_1.log"
      with open(filepath_batch_1, "w") as file:
          autotvm.callback.log_to_file(file)(
              None, inputs_batch_1, results_batch_1
          )
  
      inputs_batch_2 = [
          MeasureInput(target, tsk, tsk.config_space.get(i))
          for i in range(2, 4)
      ]
      results_batch_2 = [
          MeasureResult((0.5,), 0, 0, 0),
          MeasureResult((3,), 0, 0, 0),
      ]
      filepath_batch_2 = tmpdir / "batch_2.log"
      with open(filepath_batch_2, "w") as file:
          autotvm.callback.log_to_file(file)(
              None, inputs_batch_2, results_batch_2
          )
  
      # Check two Path filepaths works
      hist_best = ApplyHistoryBest([filepath_batch_1, filepath_batch_2])
      assert str(hist_best.query(target, tsk.workload)) == best
  
      # Check that an arbitrary Iterable of Paths works
      # Calling zip() on a single list gives a non-subscriptable Iterable
      hist_best = ApplyHistoryBest(
          zip([filepath_batch_1, filepath_batch_2])
      )
      assert str(hist_best.query(target, tsk.workload)) == best
  
      # Check that Iterable of Iterable of tuples is correctly merged
      hist_best = ApplyHistoryBest(
          zip(
              [
                  zip(inputs_batch_1, results_batch_1),
                  zip(inputs_batch_2, results_batch_2),
              ]
          )
      )
      assert str(hist_best.query(target, tsk.workload)) == best
  
file_path: tvm/tests/python/autotvm/test_autotvm_record.py
imports: from io import StringIO
  from os import PathLike
  import time
  from tvm.contrib import utils
  from tvm import autotvm
  from tvm.autotvm.measure import MeasureInput, MeasureResult, MeasureErrorNo
  from tvm.autotvm.record import encode, decode, ApplyHistoryBest, measure_str_key
  from tvm.testing.autotvm import get_sample_task
label_desc: Use image node_id 4 for calling a global function with example usage: test_apply_history_best_multiple_batches(tmpdir) without return types