<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, data, timeout_ms=None):
 """Write data to this stream. Args: data: Data to write. timeout_ms: Timeout to use for the write/Ack transaction, in milliseconds (or as a PolledTimeout object). Raises: AdbProtocolError: If an ACK is not received. AdbStreamClosedError: If the stream is already closed, or gets closed before the write completes. """

    timeout = timeouts.PolledTimeout.from_millis(timeout_ms)
    # Break the data up into our transport's maxdata sized WRTE messages.
    while data:
      self._transport.write(
          data[:self._transport.adb_connection.maxdata], timeout)
      data = data[self._transport.adb_connection.maxdata:]