human
Complete this python program:
def debug(rule, file=None):
assistant
#Here is the Python code you requested.

    """Print out before and after expressions each time rule is used
    """
    if (file is None):
        from sys import stdout
        file = stdout
    def debug_rl(*args, **kwargs):
        expr = args[0]
        result = rule(*args, **kwargs)
        if (result != expr):
            file.write(('Rule:    %s\n' % get_function_name(rule)))
            file.write(('In:            %s\nOut:        %s\n\n' % (expr, result)))
        return result
    return debug_rl