code: def test_meta_schedule_pydatabase_override_query():
      mod: IRModule = Matmul
      target = tvm.target.Target("llvm")
      arg_info = ms.arg_info.ArgInfo.from_prim_func(func=mod["main"])
      db = PyMemoryDatabaseOverride()  # pylint: disable=invalid-name
      sch = _create_schedule(mod, _schedule_matmul)
      trace = sch.trace
  
      def query(db, mod, target, kind):  # pylint: disable=invalid-name
          return db.query(
              mod=mod, target=target, workload_name="main", kind=kind
          )
  
      def commit_record(
          trace, db, run_sec
      ):  # pylint: disable=invalid-name
          db.commit_tuning_record(
              ms.database.TuningRecord(
                  trace,
                  workload=db.commit_workload(mod),
                  run_secs=[run_sec],
                  target=target,
                  args_info=arg_info,
              )
          )
  
      commit_record(trace, db, 1.14)
      record = query(db, mod, target, "record")
      assert record is not None and record.run_secs[0].value == 1.14
      sch_res = query(db, mod, target, "schedule")
      assert sch_res is not None and tvm.ir.structural_equal(
          sch_res.mod, sch.mod
      )
      mod_res = query(db, mod, target, "ir_module")
      assert mod_res is not None and tvm.ir.structural_equal(
          mod_res, sch.mod
      )
  
      commit_record(Schedule(mod).trace, db, 0.514)  # Empty Trace
      record = query(db, mod, target, "record")
      assert (
          record is not None and record.run_secs[0].value == 1.14
      )  # Override to 2nd best
      sch_res = query(db, mod, target, "schedule")
      assert sch_res is not None and tvm.ir.structural_equal(
          sch_res.mod, sch.mod
      )
      mod_res = query(db, mod, target, "ir_module")
      assert mod_res is not None and tvm.ir.structural_equal(
          mod_res, sch.mod
      )
  
imports: import os.path
  import tempfile
  from typing import Callable, List, Optional
  import pytest
  import tvm
  import tvm.testing
  from tvm import meta_schedule
  from tvm import relay, tir
  from tvm.ir.module import IRModule
  from tvm.meta_schedule.database import TuningRecord, Workload
  from tvm.script import tir
  from tvm.target import Target
  from tvm.tir import Schedule
label_desc: Use image node_id 14 for calling a global function with example usage: test_meta_schedule_pydatabase_override_query() and returns: db