code: def test_file_io():
      temp = utils.tempdir()
      file_path = temp.relpath("temp.log")
  
      tsk, target = get_sample_task()
      inputs = [
          MeasureInput(target, tsk, tsk.config_space.get(i))
          for i in range(0, 10)
      ]
      results = [MeasureResult((i,), 0, 0, 0) for i in range(0, 10)]
  
      invalid_inp = MeasureInput(target, tsk, tsk.config_space.get(10))
      invalid_res = MeasureResult((10,), 0, 0, 0)
  
      # Erase the entity map to test if it will be ignored when loading back.
      invalid_inp.config._entity_map = {}
  
      with open(file_path, "w") as fo:
          cb = autotvm.callback.log_to_file(fo)
          cb(None, inputs, results)
          cb(None, [invalid_inp], [invalid_res])
  
      ref = zip(inputs, results)
      for x, y in zip(ref, autotvm.record.load_from_file(file_path)):
          assert x[1] == y[1]
  
      # Confirm functionality of multiple file loads
      hist_best = ApplyHistoryBest([file_path, file_path])
      x = hist_best.query(target, tsk.workload)
      assert str(x) == str(inputs[0][2])
  
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 2 for calling a global function with example usage: test_file_io() without return types