code: def _get_getch_impl_macos() -> Optional[Callable[[], str]]:
      try:
          # try OS/X API
          import Carbon  # type: ignore
  
          # unix doesn't have this
          Carbon.Evt
      except:
          return None
  
      def _getch():
          if (
              Carbon.Evt.EventAvail(0x0008)[0] == 0
          ):  # 0x0008 is the keyDownMask
              return ""
          else:
              (what, msg, when, where, mod) = Carbon.Evt.GetNextEvent(
                  0x0008
              )[1]
              ch = chr(msg & 0x000000FF)
              if ord(ch) == 3:
                  raise KeyboardInterrupt
              return ch
  
      return _getch
  
file_path: vowpal_wabbit/utl/active_interactor.py
imports: import socket
  import argparse
  from typing import Callable, ContextManager, Optional, TextIO
  import contextlib
label_desc: Use image node_id 4 for calling a global function with example usage: _get_getch_impl_macos() and returns: _getch, None, str, ch