code: def spacy_wrap(
      fn: Callable, language: str = "en_core_web_sm", **kwargs
  ) -> Callable:
      """
      Wrap the function so that it runs the input text data
      through a spacy model before the function call.
      """
      from allennlp.common.util import get_spacy_model
  
      def new_fn(data: Union[spacy.tokens.doc.Doc, Dict, str]):
          if not isinstance(data, spacy.tokens.doc.Doc):
              model = get_spacy_model(language, **kwargs)
              if isinstance(data, Dict):
                  for key, val in data.items():
                      if isinstance(val, str):
                          data[key] = model(val)
              elif isinstance(data, tuple):
                  data = tuple(
                      model(tup) if isinstance(tup, str) else tup
                      for tup in data
                  )
              elif isinstance(data, str):
                  data = model(data)
              else:
                  pass
          return fn(data)
  
      return new_fn
  
file_path: allennlp/allennlp/confidence_checks/task_checklists/utils.py
imports: import string
  from typing import Dict, Callable, List, Union
  import numpy
  import spacy
  from checklist.editor import Editor
label_desc: Use image node_id 2 for calling a global function with example usage: spacy_wrap(fn, language) and returns: new_fn, fn