class_docstr: NNI wraps `hyperopt <https://github.com/hyperopt/hyperopt>`__ to provide anneal tuner.
  
  This simple annealing algorithm begins by sampling from the prior
  but tends over time to sample from points closer and closer to the best ones observed.
  This algorithm is a simple variation of random search that leverages smoothness in the response surface.
  The annealing rate is not adaptive.
  
  Note that it needs additional installation using the following command:
  
  .. code-block:: bash
  
      pip install nni[Anneal]
  
  Examples
  --------
  
  .. code-block::
  
      config.tuner.name = 'Anneal'
      config.tuner.class_args = {
          'optimize_mode': 'minimize'
      }
  
  Parameters
  ----------
  optimze_mode: 'minimize' or 'maximize'
      Whether optimize to minimize or maximize trial result.
class_docstr_tok: ["NNI","wraps","`","hyperopt","<","https",":","\/\/github.com\/hyperopt\/hyperopt",">","`","__","to","provide","anneal","tuner",".","This","simple","annealing","algorithm","begins","by","sampling","from","the","prior","but","tends","over","time","to","sample","from","points","closer","and","closer","to","the","best","ones","observed",".","This","algorithm","is","a","simple","variation","of","random","search","that","leverages","smoothness","in","the","response","surface",".","The","annealing","rate","is","not","adaptive",".","Note","that","it","needs","additional","installation","using","the","following","command",":","..","code-block",":",":","bash","pip","install","nni","[","Anneal","]","Examples","--","--","--","--","..","code-block",":",":","config.tuner.name","=","'Anneal'","config.tuner.class_args","=","{","'optimize_mode","'",":","'minimize'","}","Parameters","--","--","--","--","--","optimze_mode",":","'minimize","'","or","'maximize'","Whether","optimize","to","minimize","or","maximize","trial","result","."]
code: def receive_trial_result(
      self, parameter_id, parameters, value, **kwargs
  ):
      reward = extract_scalar_reward(value)
      # restore the paramsters contains '_index'
      if parameter_id not in self.total_data:
          raise RuntimeError("Received parameter_id not in total_data.")
      params = self.total_data[parameter_id]
  
      # code for parallel
      if self.parallel:
          constant_liar = kwargs.get("constant_liar", False)
  
          if constant_liar:
              rval = self.CL_rval
          else:
              rval = self.rval
              # ignore duplicated reported final result (due to aware of intermedate result)
              if parameter_id not in self.running_data:
                  logger.info(
                      "Received duplicated final result with parameter id: %s",
                      parameter_id,
                  )
                  return
              self.running_data.remove(parameter_id)
  
              # update the reward of optimal_y
              if self.optimal_y is None:
                  if self.constant_liar_type == "mean":
                      self.optimal_y = [reward, 1]
                  else:
                      self.optimal_y = reward
              else:
                  if self.constant_liar_type == "mean":
                      _sum = self.optimal_y[0] + reward
                      _number = self.optimal_y[1] + 1
                      self.optimal_y = [_sum, _number]
                  elif self.constant_liar_type == "min":
                      self.optimal_y = min(self.optimal_y, reward)
                  elif self.constant_liar_type == "max":
                      self.optimal_y = max(self.optimal_y, reward)
              logger.debug(
                  "Update optimal_y with reward, optimal_y = %s",
                  self.optimal_y,
              )
      else:
          rval = self.rval
  
      if self.optimize_mode is OptimizeMode.Maximize:
          reward = -reward
  
      domain = rval.domain
      trials = rval.trials
  
      new_id = len(trials)
  
      rval_specs = [None]
      rval_results = [domain.new_result()]
      rval_miscs = [
          dict(tid=new_id, cmd=domain.cmd, workdir=domain.workdir)
      ]
  
      vals = params
      idxs = dict()
  
      out_y = dict()
      json2vals(self.json, vals, out_y)
      vals = out_y
      for key in domain.params:
          if key in [NodeType.VALUE, NodeType.INDEX]:
              continue
          if key not in vals or vals[key] is None or vals[key] == []:
              idxs[key] = vals[key] = []
          else:
              idxs[key] = [new_id]
              vals[key] = [vals[key]]
  
      self._miscs_update_idxs_vals(
          rval_miscs,
          idxs,
          vals,
          idxs_map={new_id: new_id},
          assert_all_vals_used=False,
      )
  
      trial = trials.new_trial_docs(
          [new_id], rval_specs, rval_results, rval_miscs
      )[0]
      trial["result"] = {"loss": reward, "status": "ok"}
      trial["state"] = hp.JOB_STATE_DONE
      trials.insert_trial_docs([trial])
      trials.refresh()
  
imports: import copy
  import logging
  import hyperopt
  import numpy
  from schema import Optional, Schema
  from nni import ClassArgsValidator
  from nni.common.hpo_utils import validate_search_space
  from nni.tuner import Tuner
  from nni.utils import NodeType, OptimizeMode, extract_scalar_reward, split_index
label_desc: Use image node_id 5 for calling the HyperoptTuner obj's underlying member method code with example usage: obj.receive_trial_result(parameter_id, parameters, value) without return types