def extrinsic_eval(logger, summary_writer, sample_result, metric_list, detail_type, global_step, epoch):
    predict_text = []
    label_text = []
    for sample in sample_result:
        predict_text.append(sample['predict']['text'])
        label_text.append([])
        for answer in sample['answers']:
            label_text[(- 1)].append(answer['text'])
    eval_result_list = []
    sample_output = sample_result
    for metric in metric_list:
        score = evaluate_from_data(predict_text, label_text, metric)
        summary_writer.add_value_summary(metric, score, global_step)
        eval_result = ExtrinsicEvalLog(metric=metric, score=score, sample_output=None, sample_size=len(sample_output))
        eval_result_list.append(eval_result)
    if (detail_type == 'simplified'):
        sample_output = {sample['id']: sample['predict']['text'] for sample in sample_output}
    eval_result_detail = ExtrinsicEvalLog(metric='detail', score=0.0, sample_output=sample_output, sample_size=len(sample_output))
    basic_info = BasicInfoEvalLog(epoch=epoch, global_step=global_step)
    logger.update_extrinsic_eval(eval_result_list, basic_info)
    logger.update_extrinsic_eval_detail(eval_result_detail, basic_info)
    logger.check_extrinsic_eval()
    logger.check_extrinsic_eval_detail()
def extrinsic_eval(logger, summary_writer, sample_result, metric_list, detail_type, global_step, epoch):
    predict_text = []
    label_text = []
    for sample in sample_result:
        predict_text.append(sample['predict']['text'])
        label_text.append([])
        for answer in sample['answers']:
            label_text[(- 1)].append(answer['text'])
    eval_result_list = []
    sample_output = sample_result
    for metric in metric_list:
        score = evaluate_from_data(predict_text, label_text, metric)
        summary_writer.add_value_summary(metric, score, global_step)
        eval_result = ExtrinsicEvalLog(metric=metric, score=score, sample_output=None, sample_size=len(sample_output))
        eval_result_list.append(eval_result)
    if (detail_type == 'simplified'):
        sample_output = {sample['id']: sample['predict']['text'] for sample in sample_output}
    eval_result_detail = ExtrinsicEvalLog(metric='detail', score=0.0, sample_output=sample_output, sample_size=len(sample_output))
    basic_info = BasicInfoEvalLog(epoch=epoch, global_step=global_step)
    logger.update_extrinsic_eval(eval_result_list, basic_info)
    logger.update_extrinsic_eval_detail(eval_result_detail, basic_info)
    logger.check_extrinsic_eval()
    logger.check_extrinsic_eval_detail()