<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 write(self, writer: Any, close_boundary: bool=True) -> None: """Write body."""

        if not self._parts:
            return

        for part, encoding, te_encoding in self._parts:
            await writer.write(b'--' + self._boundary + b'\r\n')
            await writer.write(part._binary_headers)

            if encoding or te_encoding:
                w = MultipartPayloadWriter(writer)
                if encoding:
                    w.enable_compression(encoding)
                if te_encoding:
                    w.enable_encoding(te_encoding)
                await part.write(w)  # type: ignore
                await w.write_eof()
            else:
                await part.write(writer)

            await writer.write(b'\r\n')

        if close_boundary:
            await writer.write(b'--' + self._boundary + b'--\r\n')