human
Complete the below
def filter_interdiff_opcodes(opcodes, filediff_data, interfilediff_data):

    ''''Filters the opcodes for an interdiff to remove unnecessary lines.
    An interdiff may contain lines of code that have changed as the result of
    updates to the tree between the time that the first and second diff were
    created. This leads to some annoyances when reviewing.
    This function will filter the opcodes to remove as much of this as
    possible. It will only output non-"equal" opcodes if it falls into the
    ranges of lines dictated in the uploaded diff files.'
    '''

Write me a the Python program you requested?
assistant
#Here is the Python program you requested.
    def _find_range_info(diff):
        lines = split_line_endings(diff)
        process_changes = False
        process_trailing_context = False
        ranges = []
        chunk_start = None
        chunk_len = 0
        lines_of_context = 0
        for line in lines:
            if process_changes:
                if line.startswith(('-', '+')):
                    start = ((chunk_start - 1) + lines_of_context)
                    chunk_len -= lines_of_context
                    if (lines_of_context > 0):
                        start -= 1
                    ranges.append((start, (start + chunk_len)))
                    process_changes = False
                    process_trailing_context = True
                    lines_of_context = 0
                    continue
                else:
                    lines_of_context += 1
            elif process_trailing_context:
                if line.startswith('    '):
                    lines_of_context += 1
                    continue
                else:
                    lines_of_context = 0
            m = CHUNK_RANGE_RE.match(line)
            if m:
                if (process_trailing_context and (lines_of_context > 0)):
                    last_range = ranges[(-1)]
                    ranges[(-1)] = (last_range[0], (last_range[1] - lines_of_context))
                chunk_start = int(m.group(u'new_start'))
                chunk_len = int((m.group(u'new_len') or u'1'))
                process_changes = True
                process_trailing_context = False
                lines_of_context = 0
        if (process_trailing_context and (lines_of_context > 0)):
            last_range = ranges[(-1)]
            ranges[(-1)] = (last_range[0], (last_range[1] - lines_of_context))
        return ranges
    def _is_range_valid(line_range, tag, i1, i2):
        return ((line_range is not None) and (i1 >= line_range[0]) and ((tag == u'delete') or (i1 != i2)))
    orig_ranges = _find_range_info(filediff_data)
    new_ranges = _find_range_info(interfilediff_data)
...