<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tangle(*args, **kwargs):
 """ Shortcut to create a new, custom Tangle model. Use instead of directly subclassing `Tangle`. A new, custom Widget class is created, with each of `kwargs` as a traitlet. Returns an instance of the new class with default values. `kwargs` options - primitive types (int, bool, float) will be created as casting versions (`CInt`, `CBool`, `CFloat`) - a `list` will be created as an `Enum` - a `Widget` instance will create a link to that widget's `value` - a `tuple` `(widget_instance, "traitlet")` will create a `link` - functions will be `inspect`ed to find their argument names subscribed for - a `tuple` `(function, default)` will be created as the type (as above) """


    class_attrs = {
        "_links": [],
        "_dlinks": [],
        "_derived": {}
    }

    for value in args:
        if isinstance(value, function):
            # we'll just go ahead and assume this was made by `interact`
            if hasattr(value, "widget") and hasattr(value.widget, "children"):
                for child in value.widget.children:
                    _link_widget(child.description, child, class_attrs)

    for key, value in kwargs.items():
        traitlet_cls = _get_primitive(value)
        traitlet_args = [value]
        traitlet_kwargs = {
            "sync": True
        }

        handled = False

        if traitlet_cls is not None:
            pass
        elif isinstance(value, list):
            traitlet_cls = Any
            traitlet_args = [value[0]]
            class_attrs["{}_options".format(key)] = Tuple(value, sync=True)
        elif isinstance(value, Widget):
            _link_widget(key, value, class_attrs)
            handled = True
        elif isinstance(value, tuple):
            if isinstance(value[0], Widget):
                widget, traitlet = value
                widget_cls = widget.__class__
                traitlet_args = []
                traitlet_cls = getattr(widget_cls, traitlet).__class__
                class_attrs["_links"].append((key, value))
            elif hasattr(value[1], "__call__"):
                example, fn = value
                traitlet_args = [example]
                traitlet_cls = _get_primitive(example)

                subscribed = inspect.getargspec(fn).args

                class_attrs["_derived"][key] = (fn, subscribed)

        if not handled:
            if traitlet_cls is None:
                raise ValueError("Didn't understand {}: {}".format(key, value))
            class_attrs[key] = traitlet_cls(*traitlet_args, **traitlet_kwargs)

    new_class = type(
        'DynamicAutoTangle{}'.format(id(class_attrs)),
        (AutoTangle,),
        class_attrs
    )

    inst = new_class()
    return inst._refresh()