code: def _get_unicode_checker():
      """
      Returns a doctest.OutputChecker subclass that takes in account the
      ALLOW_UNICODE option to ignore u'' prefixes in strings. Useful
      when the same doctest should run in Python 2 and Python 3.
  
      An inner class is used to avoid importing "doctest" at the module
      level.
      """
      if hasattr(_get_unicode_checker, "UnicodeOutputChecker"):
          return _get_unicode_checker.UnicodeOutputChecker()
  
      import doctest
      import re
  
      class UnicodeOutputChecker(doctest.OutputChecker):
          """
          Copied from doctest_nose_plugin.py from the nltk project:
              https://github.com/nltk/nltk
          """
  
          _literal_re = re.compile(
              r"(\W|^)[uU]([rR]?[\'\"])", re.UNICODE
          )
  
          def check_output(self, want, got, optionflags):
              res = doctest.OutputChecker.check_output(
                  self, want, got, optionflags
              )
              if res:
                  return True
  
              if not (optionflags & _get_allow_unicode_flag()):
                  return False
  
              else:  # pragma: no cover
                  # the code below will end up executed only in Python 2 in
                  # our tests, and our coverage check runs in Python 3 only
                  def remove_u_prefixes(txt):
                      return re.sub(self._literal_re, r"\1\2", txt)
  
                  want = remove_u_prefixes(want)
                  got = remove_u_prefixes(got)
                  res = doctest.OutputChecker.check_output(
                      self, want, got, optionflags
                  )
                  return res
  
      _get_unicode_checker.UnicodeOutputChecker = UnicodeOutputChecker
      return _get_unicode_checker.UnicodeOutputChecker()
  
imports: from __future__ import annotations
  import doctest
  import logging
  import os
  import re
  import sys
  from sqlalchemy.testing import config
  from sqlalchemy.testing import fixtures
  from sqlalchemy.testing import requires
label_desc: Use image node_id 1 for calling a global function with example usage: _get_unicode_checker() and returns: _get_unicode_checker, _get_unicode_checker, True, False, res, re