human
Complete this python program:
def _interpret_hadoop_jar_command_stderr(stderr, record_callback=None):
assistant
#Here is the Python code you requested.

    """Parse stderr from the ``hadoop jar`` command. Works like
    :py:func:`_parse_step_syslog` (same return format)  with a few extra
    features to handle the output of the ``hadoop jar`` command on the fly:
    - Converts ``bytes`` lines to ``str``
    - Pre-filters non-log4j stuff from Hadoop Streaming so it doesn\t
    get treated as part of a multi-line message
    - Handles "stderr" from a PTY (including treating EIO as EOF and
    pre-filtering stdout lines from Hadoop Streaming)
    - Optionally calls *record_callback* for each log4j record (see
    :py:func:`~mrjob.logs.log4j._parse_hadoop_log4j_records`).
    """
    def yield_lines():
        try:
            for line in stderr:
                (yield to_unicode(line))
        except IOError as e:
            if (e.errno == errno.EIO):
                return
            else:
                raise
    def pre_filter(line):
        return bool(_HADOOP_STREAMING_NON_LOG4J_LINE_RE.match(line))
    def yield_records():
        for record in _parse_hadoop_log4j_records(yield_lines(), pre_filter=pre_filter):
            if record_callback:
                record_callback(record)
            (yield record)
    result = _parse_step_syslog_from_log4j_records(yield_records())
    _add_implied_job_id(result)
    for error in (result.get('errors') or ()):
        _add_implied_task_id(error)
    return result