<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def insert_comment(event):
 """ Without numeric argument, comment all lines. With numeric argument, uncomment all lines. In any case accept the input. """

    buff = event.current_buffer

    # Transform all lines.
    if event.arg != 1:
        def change(line):
            return line[1:] if line.startswith('#') else line
    else:
        def change(line):
            return '#' + line

    buff.document = Document(
        text='\n'.join(map(change, buff.text.splitlines())),
        cursor_position=0)

    # Accept input.
    buff.accept_action.validate_and_handle(event.cli, buff)