<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def draw_str(self, x, y, string, fg=Ellipsis, bg=Ellipsis):
 """Draws a string starting at x and y. A string that goes past the right side will wrap around. A string wrapping to below the console will raise :any:`tdl.TDLError` but will still be written out. This means you can safely ignore the errors with a try..except block if you're fine with partially written strings. \\r and \\n are drawn on the console as normal character tiles. No special encoding is done and any string will translate to the character table as is. For a string drawing operation that respects special characters see :any:`print_str`. Args: x (int):
 x-coordinate to start at. y (int):
 y-coordinate to start at. string (Union[Text, Iterable[int]]):
 A string or an iterable of numbers. Special characters are ignored and rendered as any other character. fg (Optional[Union[Tuple[int, int, int], int, Ellipsis]]) bg (Optional[Union[Tuple[int, int, int], int, Ellipsis]]) Raises: AssertionError: Having x or y values that can't be placed inside of the console will raise an AssertionError. You can use always use ``((x, y) in console)`` to check if a tile is drawable. .. seealso:: :any:`print_str` """


        x, y = self._normalizePoint(x, y)
        fg, bg = _format_color(fg, self._fg), _format_color(bg, self._bg)
        width, height = self.get_size()
        def _drawStrGen(x=x, y=y, string=string, width=width, height=height):
            """Generator for draw_str

            Iterates over ((x, y), ch) data for _set_batch, raising an
            error if the end of the console is reached.
            """
            for char in _format_str(string):
                if y == height:
                    raise TDLError('End of console reached.')
                yield((x, y), char)
                x += 1 # advance cursor
                if x == width: # line break
                    x = 0
                    y += 1
        self._set_batch(_drawStrGen(), fg, bg)