def METHOD_NAME(self, metrics):
    intermediate_result = {}
    final_result = {}
    for metric in metrics:
        # metrics value are encoded by NNI SDK as json string,
        # here we decode the value by json.loads twice
        metric_value = json.loads(json.loads(metric['data']))
        if metric['type'] == 'PERIODICAL':
            if metric['trialJobId'] in intermediate_result:
                intermediate_result[metric['trialJobId']].append(metric_value)
            else:
                intermediate_result[metric['trialJobId']] = [metric_value]
        elif metric['type'] == 'FINAL':
            if metric['trialJobId'] in final_result:
                final_result[metric['trialJobId']].append(metric_value)
            else:
                final_result[metric['trialJobId']] = [metric_value]
    return intermediate_result, final_result