code: def get_tagged_docs(X, model="nltk", tagger="word"):
      """
      X is a list of strings; each string is a single document.
      For each document, perform part-of-speech tagging, and
      yield a list of sentences, where each sentence is a list
      of (token, tag) tuples
  
      If model=="nltk", `NLTK` will be used to sentence and word
      tokenize the incoming documents. User may select the `NLTK`
      tagger to be used; (for now) either the word tokenizer or the
      workpunct tokenizer.
  
      If model=="spacy", `SpaCy` will be used to sentence and word
      tokenize the incoming documents.
      """
      if model == "spacy":
          nlp = spacy.load("en_core_web_sm")
          for doc in X:
              tagged = nlp(doc)
              yield [
                  list((token.text, token.pos_) for token in sent)
                  for sent in tagged.sents
              ]
  
      elif model == "nltk":
          if tagger == "wordpunct":
              for doc in X:
                  yield [
                      pos_tag(wordpunct_tokenize(sent))
                      for sent in sent_tokenize(doc)
                  ]
          else:
              for doc in X:
                  yield [
                      pos_tag(word_tokenize(sent))
                      for sent in sent_tokenize(doc)
                  ]
  
imports: import pytest
  import matplotlib.pyplot
  from tests.base import VisualTestCase
  from tests.base import IS_WINDOWS_OR_CONDA
  from yellowbrick.text.postag import *
  from yellowbrick.exceptions import YellowbrickValueError
label_desc: Use image node_id 3 for calling a global function with example usage: get_tagged_docs(X, model, tagger) without return types