code: def select_implementation(
      op, attrs, inputs, out_type, target, use_autotvm=True
  ):
      """Select the best implementation from the op strategy.
  
      If use_autotvm is True, it'll first try to find the best implementation
      based on AutoTVM profile results. If no AutoTVM profile result is found,
      it'll choose the implementation with highest plevel.
  
      If use_autotvm is False, it'll directly choose the implementation with
      highest plevel.
  
      Note that this function doesn't support op with symbolic input shapes.
  
      Parameters
      ----------
      op : tvm.ir.Op
          Relay operator.
  
      attrs : object
          The op attribute.
  
      inputs : List[tvm.te.Tensor]
          Input tensors to the op.
  
      out_type : relay.Type
          The output type.
  
      target : tvm.target.Target
          The target to compile the op.
  
      use_autotvm : bool
          Whether query AutoTVM to pick the best.
  
      Returns
      -------
      ret : tuple(relay.op.OpImplementation, List[tvm.te.Tensor])
          The best op implementation and the corresponding output tensors.
      """
      all_impls = get_valid_implementations(
          op, attrs, inputs, out_type, target
      )
      if len(all_impls) == 0:
          raise RuntimeError(
              f"No valid {op} implementations for {target}"
          )
      best_plevel_impl = max(all_impls, key=lambda x: x.plevel)
  
      # Disable autotvm if auto_scheduler is enabled.
      # (i.e., always return the implementation with the highest priority for auto-scheduler).
      if is_auto_scheduler_enabled() or is_meta_schedule_enabled():
          use_autotvm = False
  
      # If not use autotvm, always return the implementation with the highest priority
      if not use_autotvm:
          logger.info(
              "Using %s for %s based on highest priority (%d)",
              best_plevel_impl.name,
              op.name,
              best_plevel_impl.plevel,
          )
          outs = best_plevel_impl.compute(attrs, inputs, out_type)
          return best_plevel_impl, outs
  
      # Otherwise, try autotvm templates
      outputs = {}
      workloads = {}
      best_autotvm_impl = None
      best_cfg = None
      dispatch_ctx = autotvm.task.DispatchContext.current
      old_silent = autotvm.GLOBAL_SCOPE.silent
      autotvm.GLOBAL_SCOPE.silent = True
      for impl in all_impls:
          outs = impl.compute(attrs, inputs, out_type)
          outputs[impl] = outs
          workload = autotvm.task.get_workload(outs)
          workloads[impl] = workload
          if workload is None:
              # Not an AutoTVM tunable implementation
              continue
          cfg = dispatch_ctx.query(target, workload)
          if cfg.is_fallback:
              # Skip fallback config
              continue
          logger.info(
              "Implementation %s for %s has cost %.2e",
              impl.name,
              op.name,
              cfg.cost,
          )
          if best_cfg is None or best_cfg.cost > cfg.cost:
              best_autotvm_impl = impl
              best_cfg = cfg
      autotvm.GLOBAL_SCOPE.silent = old_silent
  
      if best_autotvm_impl:
          # The best autotvm implementation definitely doesn't use fallback config
          logger.info(
              "Using %s for %s based on lowest cost (%.2e)",
              best_autotvm_impl.name,
              op.name,
              best_cfg.cost,
          )
          return best_autotvm_impl, outputs[best_autotvm_impl]
  
      # Use the implementation with highest plevel
      if workloads[best_plevel_impl] is not None:
          msg = (
              "Cannot find tuning records for:\n    target=%s\n    key=%s\n"
              "TVM will apply a default schedule which may negatively impact performance."
              % (target, workloads[best_plevel_impl])
          )
          if (
              not autotvm.env.GLOBAL_SCOPE.silent
              and msg
              not in autotvm.task.DispatchContext.warning_messages
          ):
              autotvm.task.DispatchContext.warning_messages.add(msg)
              global _first_warning
              if _first_warning:
                  _first_warning = False
                  info_msg = (
                      "One or more operators have not been tuned. Please tune your model "
                      "for better performance. Use DEBUG logging level to see more details."
                  )
                  autotvm_logger.warning(info_msg)
              autotvm_logger.debug(msg)
  
      logger.info(
          "Using %s for %s based on highest priority (%s)",
          best_plevel_impl.name,
          op.name,
          best_plevel_impl.plevel,
      )
      return best_plevel_impl, outputs[best_plevel_impl]
  
imports: from __future__ import absolute_import
  import logging
  import numpy
  import tvm
  from tvm import autotvm, te
  from tvm.auto_scheduler import is_auto_scheduler_enabled
  from tvm.meta_schedule import is_meta_schedule_enabled
  from tvm.runtime import Object
  from tvm.support import libinfo
  from tvm.target import Target
  from ..None import function
  from ..None import ty
  from ..backend.utils import mangle_module_name
  from .None import _backend
label_desc: Use image node_id 3 for calling a global function with example usage: select_implementation(op, attrs, inputs, out_type, target, use_autotvm) and returns: best_plevel_impl,  outputs, best_plevel_impl,  outs, best_autotvm_impl,  outputs