<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def stdout_writer():
 """ This is a bit complex, as stdout can be a pipe or a file. If it is a file, we cannot use :meth:`asycnio.BaseEventLoop.connect_write_pipe`. """

    if sys.stdout.seekable():
        # it’s a file
        return sys.stdout.buffer.raw

    if os.isatty(sys.stdin.fileno()):
        # it’s a tty, use fd 0
        fd_to_use = 0
    else:
        fd_to_use = 1

    twrite, pwrite = await loop.connect_write_pipe(
        asyncio.streams.FlowControlMixin,
        os.fdopen(fd_to_use, "wb"),
    )

    swrite = asyncio.StreamWriter(
        twrite,
        pwrite,
        None,
        loop,
    )

    return swrite