code: def _captured_script(script):
      r, w = os.pipe()
      indented = script.replace("\n", "\n                ")
      wrapped = dedent(
          f"""
          import contextlib
          with open({w}, 'w', encoding='utf-8') as spipe:
              with contextlib.redirect_stdout(spipe):
                  {indented}
          """
      )
      return wrapped, open(r, encoding="utf-8")
  
imports: import contextlib
  import os
  import os.path
  import subprocess
  import sys
  import tempfile
  import threading
  from textwrap import dedent
  import unittest
  from test import support
  from test.support import os_helper
  from test.support import interpreters
label_desc: Use image node_id 1 for calling a global function with example usage: _captured_script(script) and returns: wrapped,  open