docstr: data: a dict received from nni_manager, which contains:
        - 'parameter_id': id of the trial
        - 'value': metric value reported by nni.report_final_result()
        - 'type': report type, support {'FINAL', 'PERIODICAL'}
docstr_tok: ["data",":","a","dict","received","from","nni_manager",",","which","contains",":","-","'parameter_id","'",":","id","of","the","trial","-","'value","'",":","metric","value","reported","by","nni.report_final_result","(",")","-","'type","'",":","report","type",",","support","{","'FINAL","'",",","'PERIODICAL","'","}"]
code: def handle_report_metric_data(self, data):
      """
      data: a dict received from nni_manager, which contains:
            - 'parameter_id': id of the trial
            - 'value': metric value reported by nni.report_final_result()
            - 'type': report type, support {'FINAL', 'PERIODICAL'}
      """
      if self.is_created_in_previous_exp(data["parameter_id"]):
          if data["type"] == MetricType.FINAL:
              # only deal with final metric using import data
              param = self.get_previous_param(data["parameter_id"])
              trial_data = [
                  {"parameter": param, "value": load(data["value"])}
              ]
              self.handle_import_data(trial_data)
          return
      # metrics value is dumped as json string in trial, so we need to decode it here
      if "value" in data:
          data["value"] = load(data["value"])
      if data["type"] == MetricType.FINAL:
          self._handle_final_metric_data(data)
      elif data["type"] == MetricType.PERIODICAL:
          if self.assessor is not None:
              self._handle_intermediate_metric_data(data)
      elif data["type"] == MetricType.REQUEST_PARAMETER:
          assert multi_phase_enabled()
          assert data["trial_job_id"] is not None
          assert data["parameter_index"] is not None
          param_id = _create_parameter_id()
          try:
              param = self.tuner.generate_parameters(
                  param_id, trial_job_id=data["trial_job_id"]
              )
          except NoMoreTrialError:
              param = None
          self.send(
              CommandType.SendTrialJobParameter,
              _pack_parameter(
                  param_id,
                  param,
                  trial_job_id=data["trial_job_id"],
                  parameter_index=data["parameter_index"],
              ),
          )
      else:
          raise ValueError(
              "Data type not supported: {}".format(data["type"])
          )
  
imports: import logging
  from collections import defaultdict
  from nni import NoMoreTrialError
  from nni.assessor import AssessResult
  from .common import multi_phase_enabled
  from .env_vars import dispatcher_env_vars
  from .msg_dispatcher_base import MsgDispatcherBase
  from .tuner_command_channel import CommandType
  from ..common.serializer import dump, load
  from ..utils import MetricType
label_desc: Use image node_id 10 for calling the MsgDispatcher obj's underlying member method code with example usage: obj.handle_report_metric_data(data) without return types