def METHOD_NAME(line):
    def _remove_csi(line):
        return re.sub(ansi_csi_re, b'', line)
    for match in ansi_csi_re.finditer(line):
        arg, command = match.groups()
        arg = int(arg.decode()) if arg else 1
        if command == b'A':  # cursor up
            self._line_counter -= arg
        if command == b'B':  # cursor down
            self._line_counter += arg
    return _remove_csi(line)