<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stdio_mgr(in_str=""):
 r"""Subsitute temporary text buffers for `stdio` in a managed context. Context manager. Substitutes empty :cls:`~io.StringIO`\ s for :cls:`sys.stdout` and :cls:`sys.stderr`, and a :cls:`TeeStdin` for :cls:`sys.stdin` within the managed context. Upon exiting the context, the original stream objects are restored within :mod:`sys`, and the temporary streams are closed. Parameters in_str |str| *(optional)* -- Initialization text for the :cls:`TeeStdin` substitution for `stdin`. Default is an empty string. Yields ------ in_ :cls:`TeeStdin` -- Temporary stream for `stdin`. out_ :cls:`~io.StringIO` -- Temporary stream for `stdout`, initially empty. err_ :cls:`~io.StringIO` -- Temporary stream for `stderr`, initially empty. """

    old_stdin = sys.stdin
    old_stdout = sys.stdout
    old_stderr = sys.stderr

    new_stdout = StringIO()
    new_stderr = StringIO()
    new_stdin = TeeStdin(new_stdout, in_str)

    sys.stdin = new_stdin
    sys.stdout = new_stdout
    sys.stderr = new_stderr

    yield new_stdin, new_stdout, new_stderr

    sys.stdin = old_stdin
    sys.stdout = old_stdout
    sys.stderr = old_stderr

    new_stdin.close()
    new_stdout.close()
    new_stderr.close()