code: def context(target, extra_files=None):
      """Return the dispatch context with pre-tuned parameters.
      This function will load the corresponding *.log files in AUTOTVM_TOPHUB_ROOT_PATH.
      If cannot find them, it will download them from TopHub github repo.
      Users can also add their own files in argument `extra_files`.
  
      Parameters
      ----------
      target: Target or List of Target
          The compilation targets
      extra_files: list of str, optional
          Extra log files to load
      """
      tophub_location = _get_tophub_location()
      if tophub_location == AUTOTVM_TOPHUB_NONE_LOC:
          return EmptyContext()
  
      best_context = ApplyHistoryBest([])
  
      targets = (
          target
          if isinstance(target, (Array, list, tuple))
          else [target]
      )
  
      for tgt in targets:
          if isinstance(tgt, str):
              tgt = Target(tgt)
  
          # The TOPHUB file names rely on Target's device or kind. Both these types of
          # information exist in Target.keys, but rules of filling this filed is not explicitly
          # defined, we are afraid to rely only on Target.keys. At the same time Target.device
          # is filled only if device was pointed explicitly in target string, that is not mandatory
          # and in some cases we need to get information about device from Target.keys
          # In priority order we verify:
          # 1) Target.device
          # 2) Target.keys
          # 3) Target.kind
          possible_names = []
          device = tgt.attrs.get("device", "")
          if device != "":
              possible_names.append(_alias(device))
          possible_names.extend(tgt.keys)
          possible_names.append(tgt.kind.name)
  
          all_packages = list(PACKAGE_VERSION.keys())
          for name in possible_names:
              name = _alias(name)
              if name in all_packages:
                  if not check_backend(tophub_location, name):
                      continue
  
                  filename = f"{name}_{PACKAGE_VERSION[name]}.log"
                  best_context.load(
                      Path(AUTOTVM_TOPHUB_ROOT_PATH, filename)
                  )
                  break  # only load one file to avoid some fallback template mismatch problem
  
      if extra_files:
          for filename in extra_files:
              best_context.load(filename)
  
      return best_context
  
file_path: tvm/python/tvm/autotvm/tophub.py
imports: import logging
  from os import getenv
  import sys
  from pathlib import Path
  from tvm.ir.container import Array
  from .task import ApplyHistoryBest
  from ..target import Target
  from ..contrib.download import download
  from .record import load_from_file
  from .utils import EmptyContext
label_desc: Use image node_id 3 for calling a global function with example usage: context(target, extra_files) and returns: best_context, EmptyContext