<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def to_bytes(self, request=None):
        '''Called to transform the collection of
        ``streams`` into the content string.
        This method can be overwritten by derived classes.

        :param streams: a collection (list or dictionary) containing
            ``strings/bytes`` used to build the final ``string/bytes``.
        :return: a string or bytes
        '''
        data = bytearray()
        for chunk in self.stream(request):
            if isinstance(chunk, str):
                chunk = chunk.encode(self.charset)
            data.extend(chunk)
        return bytes(data)