def _add_phrase_function(phrases: List[str], num_samples: int = 10):
    """
    Returns a function which adds each str in `phrases`
    at the end of the input string and returns that list.
    """

    def perturb_fn(inp):
        input_str = utils.strip_punctuation(inp)
        total = len(phrases)
        idx = np.random.choice(total, min(num_samples, total), replace=False)
        ret = [input_str + ". " + phrases[i] for i in idx]
        return ret

    return perturb_fn
Returns a function which adds each str in `phrases`
at the end of the input string and returns that list.
allennlp/confidence_checks/task_checklists/sentiment_analysis_suite.py