class_docstr: Apply the history best config, or sample a valid schedule if no config is found.
  
  Parameters
  ----------
  records : str or iterator of (auto_scheduler.measure.MeasureInput,                                  auto_scheduler.measure.MeasureResult)
      Collection of tuning records.
      If is str, then it should be the filename of a records log file.
      Each row of this file is an encoded record pair. Otherwise, it is an iterator.
  sample_simple_workloads: bool
      When False, sampling will not apply to simple workloads (w/o reduction).
  cost_model_file: str
      The filename of the pre-trained XGBoost cost model. If not present, then random
      model will be used.
  num_measure: int
      Meausre the top-N rank of sampled schedules on the device. The default -1 means
      no measurement and simply return the top-1 schedule ranked by the cost model.
code: def query(self, target, workload_key, has_complex_op, dag, func_name):
      if has_complex_op or self.sample_simple_workloads:
          ret = self._query_inside(target, workload_key, func_name)
      else:
          ret = super(ApplyHistoryBestOrSample, self)._query_inside(
              target, workload_key, func_name
          )
  
      if ret is None:
          ret = self._old_ctx.query(
              target, workload_key, has_complex_op, dag, func_name
          )
      return ret
  
imports: import logging
  import pathlib
  from collections.abc import Iterable
  import numpy
  from tvm.contrib.utils import tempdir
  from tvm.tir.expr import FloatImm
  from .cost_model import RandomModel, XGBModel
  from .measure import LocalRPCMeasureContext
  from .measure_record import RecordToFile, load_records
  from .search_policy import PreloadMeasuredStates, SketchPolicy
  from .search_task import SearchTask, TuningOptions
  from .utils import calc_workload_dis_factor, decode_workload_key
label_desc: Use image node_id 2 for calling the ApplyHistoryBestOrSample obj's underlying member method code with example usage: obj.query(target, workload_key, has_complex_op, dag, func_name) and returns: ret