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

    """Apply function to each value inside the sequence or dict.
    Supports both dicts and sequences, key/value pairs are
    expanded when applied to a dict.
    """
    if (is_py2 and (text == func)):
        func = unicode
    def expand_kv(kv):
        return func(*kv)
    def map_values(value):
        cls = type(value)
        if isinstance(value, dict):
            return cls(_map(expand_kv, value.items()))
        else:
            return cls(_map(func, value))
    return transform(map_values)