code: 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
  
imports: from typing import Optional, Iterable, List, Union, Tuple
  import numpy
  from checklist.test_suite import TestSuite
  from checklist.test_types import MFT, INV, DIR, Expect
  from checklist.perturb import Perturb
  from allennlp.confidence_checks.task_checklists.task_suite import TaskSuite
  from allennlp.confidence_checks.task_checklists import utils
  from allennlp.data.instance import Instance
  from allennlp.predictors import Predictor
label_desc: Use image node_id 1 for calling a global function with example usage: _add_phrase_function(phrases, num_samples) and returns: perturb_fn, ret