code: def _blocking_io(io: IO[str]) -> Iterator[None]:
      """
      Ensure that the FD for `io` is set to blocking in here.
      """
      if sys.platform == "win32":
          # On Windows, the `os` module doesn't have a `get/set_blocking`
          # function.
          yield
          return
  
      try:
          fd = io.fileno()
          blocking = os.get_blocking(fd)
      except:  # noqa
          # Failed somewhere.
          # `get_blocking` can raise `OSError`.
          # The io object can raise `AttributeError` when no `fileno()` method is
          # present if we're not a real file object.
          blocking = True  # Assume we're good, and don't do anything.
  
      try:
          # Make blocking if we weren't blocking yet.
          if not blocking:
              os.set_blocking(fd, True)
  
          yield
  
      finally:
          # Restore original blocking mode.
          if not blocking:
              os.set_blocking(fd, blocking)
  
imports: from __future__ import annotations
  import errno
  import os
  import sys
  from contextlib import contextmanager
  from typing import IO, Iterator, TextIO
label_desc: Use image node_id 2 for calling a global function with example usage: _blocking_io(io) without return types