<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resolve_deep(values, max_depth=5, types=None):
 """ Resolves all late-resolving types into their current values to a certain depth in a dictionary or list. :param values: Values to resolve of any type. :param max_depth: Maximum depth to recurse into nested lists, tuples and dictionaries. Below that depth values are returned as they are. :type max_depth: int :param: Dictionary of types and functions to resolve, that are not registered in ``type_registry``. :type: dict[unicode | str, function] :return: Resolved values. """

    def _resolve_sub(v, level):
        l1 = level + 1
        res_val = resolve_value(v, all_types)
        if l1 < max_depth:
            if isinstance(res_val, (list, tuple)):
                return [_resolve_sub(item, l1) for item in res_val]
            elif isinstance(res_val, dict):
                return {resolve_value(rk, all_types): _resolve_sub(rv, l1) for rk, rv in iteritems(res_val)}
        return res_val

    if types:
        all_types = type_registry.copy()
        all_types.update(types)
    else:
        all_types = type_registry
    return _resolve_sub(values, -1)