code: def tune(runner, kernel_options, device_options, tuning_options):
      
  
      results = []
      cache = {}
  
      method = tuning_options.method
  
      #scale variables in x to make 'eps' relevant for multiple variables
      tuning_options["scaling"] = True
  
      bounds, x0, _ = get_bounds_x0_eps(tuning_options)
      kwargs = setup_method_arguments(method, bounds)
      options = setup_method_options(method, tuning_options)
  
      #not all methods support 'disp' option
      if not method in ['TNC']:
          options['disp'] = tuning_options.verbose
  
      args = (kernel_options, tuning_options, runner, results, cache)
  
      opt_result = scipy.optimize.minimize(_cost_func, x0, args=args, method=method, options=options, **kwargs)
  
      if tuning_options.verbose:
          print(opt_result.message)
  
      return results, runner.dev.get_environment()
docs: Find the best performing kernel configuration in the parameter space
  
      :params runner: A runner from kernel_tuner.runners
      :type runner: kernel_tuner.runner
  
      :param kernel_options: A dictionary with all options for the kernel.
      :type kernel_options: kernel_tuner.interface.Options
  
      :param device_options: A dictionary with all options for the device
          on which the kernel should be tuned.
      :type device_options: kernel_tuner.interface.Options
  
      :param tuning_options: A dictionary with all options regarding the tuning
          process.
      :type tuning_options: kernel_tuner.interface.Options
  
      :returns: A list of dictionaries for executed kernel configurations and their
          execution times. And a dictionary that contains a information
          about the hardware/software environment on which the tuning took place.
      :rtype: list(dict()), dict()