def validate(summarizer, validate_dataset):
    """ validation function to be used optionally in fine tuning.

    Args:
        summarizer(BertSumAbs): The summarizer under fine tuning.
        validate_dataset (SummarizationDataset): dataset for validation.

    Returns:
        string: A string which contains the rouge score on a subset of
            the validation dataset.

    """
    TOP_N = 8
    shortened_dataset = validate_dataset.shorten(TOP_N)
    reference_summaries = [
        " ".join(t).rstrip("\n") for t in shortened_dataset.get_target()
    ]
    generated_summaries = summarizer.predict(
        shortened_dataset, num_gpus=1, batch_size=4
    )
    assert len(generated_summaries) == len(reference_summaries)
    print("###################")
    print("prediction is {}".format(generated_summaries[0]))
    print("reference is {}".format(reference_summaries[0]))

    rouge_score = compute_rouge_python(
        cand=generated_summaries, ref=reference_summaries
    )
    return "rouge score: {}".format(rouge_score)
 validation function to be used optionally in fine tuning.

    Args:
        summarizer(BertSumAbs): The summarizer under fine tuning.
        validate_dataset (SummarizationDataset): dataset for validation.

    Returns:
        string: A string which contains the rouge score on a subset of
            the validation dataset.

    
utils_nlp/models/transformers/abstractive_summarization_bertsum.py