human
Complete this python program:
def flatten_func(func, example):
assistant
#Here is the Python code you requested.

    """Flattens both the inputs to a function, and the outputs.
    """
    (flattened_example, unflatten) = flatten(example)
    def flattened_func(flattened_params, *args, **kwargs):
        output = func(unflatten(flattened_params), *args, **kwargs)
        (flattened_output, _) = flatten(output)
        return flattened_output
    return (flattened_func, unflatten, flattened_example)