<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def debug_form_contents(form: cgi.FieldStorage, to_stderr: bool = True, to_logger: bool = False) -> None: """ Writes the keys and values of a CGI form to ``stderr``. """

    for k in form.keys():
        text = "{0} = {1}".format(k, form.getvalue(k))
        if to_stderr:
            sys.stderr.write(text)
        if to_logger:
            log.info(text)