def get_pred(
    example,
    sent_scores,
    cal_lead=False,
    sentence_separator="<q>",
    block_trigram=True,
    top_n=3,
):
    """
        Get the summarization prediction for the paragraph example based on the scores
        returned by the transformer summarization model.

        Args:
            example (str): The object with "src_txt" field as the paragraph which
                requries summarization. The "src_txt" is a list of strings.
            sent_scores (list of floats): List of scores of how likely of the
                sentence is included in the summary.
            cal_lead (bool, optional): Boolean value which specifies whether the
                prediction uses the first few sentences as summary. Defaults to False.
            sentence_separator (str, optional): Seperator used in the generated summary.
                Defaults to '<q>'.
            block_trigram (bool, optional): Boolean value which specifies whether the
                summary should include any sentence that has the same trigram as the
                already selected sentences. Defaults to True.
            top_n (int, optional): The maximum number of sentences that the summary
                should included. Defaults to 3.

        Returns:
            A string which is the summary for the example.
    """

    def _get_ngrams(n, text):
        ngram_set = set()
        text_length = len(text)
        max_index_ngram_start = text_length - n
        for i in range(max_index_ngram_start + 1):
            ngram_set.add(tuple(text[i : i + n]))
        return ngram_set

    def _block_tri(c, p):
        tri_c = _get_ngrams(3, c.split())
        for s in p:
            tri_s = _get_ngrams(3, s.split())
            if len(tri_c.intersection(tri_s)) > 0:
                return True
        return False

    selected_ids = np.argsort(-sent_scores)
    # selected_ids = np.argsort(-sent_scores, 1)
    if cal_lead:
        selected_ids = range(len(example["clss"]))

    pred = []
    _pred = []
    final_selections = []
    for j in selected_ids[: len(example["src_txt"])]:
        if j >= len(example["src_txt"]):
            continue
        candidate = example["src_txt"][j].strip()
        if block_trigram:
            if not _block_tri(candidate, _pred):
                _pred.append(candidate)
                final_selections.append(j)
        else:
            _pred.append(candidate)
            final_selections.append(j)

        # only select the top n
        if len(_pred) == top_n:
            break

    sorted_selections = sorted(final_selections)
    _pred = []
    for i in sorted_selections:
        _pred.append(example["src_txt"][i].strip())
    _pred = sentence_separator.join(_pred)
    pred.append(_pred.strip())
    return pred

        Get the summarization prediction for the paragraph example based on the scores
        returned by the transformer summarization model.

        Args:
            example (str): The object with "src_txt" field as the paragraph which
                requries summarization. The "src_txt" is a list of strings.
            sent_scores (list of floats): List of scores of how likely of the
                sentence is included in the summary.
            cal_lead (bool, optional): Boolean value which specifies whether the
                prediction uses the first few sentences as summary. Defaults to False.
            sentence_separator (str, optional): Seperator used in the generated summary.
                Defaults to '<q>'.
            block_trigram (bool, optional): Boolean value which specifies whether the
                summary should include any sentence that has the same trigram as the
                already selected sentences. Defaults to True.
            top_n (int, optional): The maximum number of sentences that the summary
                should included. Defaults to 3.

        Returns:
            A string which is the summary for the example.
    
utils_nlp/models/transformers/extractive_summarization.py