human
Complete this python program:
def general_toposort(outputs, deps, debug_print=False, compute_deps_cache=None, deps_cache=None, clients=None):
assistant
#Here is the Python program you requested.

    """WRITEME
    Parameters
    deps
    A python function that takes a node as input and returns its dependence.
    compute_deps_cache : optional
    If provided deps_cache should also be provided. This is a function like
    deps, but that also cache its results in a dict passed as deps_cache.
    deps_cache : dict
    Must be used with compute_deps_cache.
    clients : dict
    If a dict is passed it will be filled with a mapping of node
    -> clients for each node in the subgraph.
    Notes
    deps(i) should behave like a pure function (no funny business with
    internal state).
    deps(i) will be cached by this function (to be fast).
    The order of the return value list is determined by the order of nodes
    returned by the deps() function.
    deps should be provided or can be None and the caller provides
    compute_deps_cache and deps_cache. The second option removes a Python
    function call, and allows for more specialized code, so it can be
    faster.
    """
    if (compute_deps_cache is None):
        deps_cache = {}
        def compute_deps_cache(io):
            if (io not in deps_cache):
                d = deps(io)
                if d:
                    if (not isinstance(d, (list, OrderedSet))):
                        raise TypeError('Non-deterministic    collections    here    make    toposort    non-deterministic.')
                    deps_cache[io] = list(d)
                else:
                    deps_cache[io] = d
                return d
            else:
                return deps_cache[io]
    assert (deps_cache is not None)
    assert isinstance(outputs, (tuple, list, deque))
    (reachable, _clients) = stack_search(deque(outputs), compute_deps_cache, 'dfs', True)
    if (clients is not None):
        clients.update(_clients)
    sources = deque([r for r in reachable if (not deps_cache.get(r, None))])
    rset = set()
    rlist = []
    while sources:
        node = sources.popleft()
        if (node not in rset):
            rlist.append(node)
            rset.add(node)
            for client in _clients.get(node, []):
                d = [a for a in deps_cache[client] if (a is not node)]
                deps_cache[client] = d
                if (not d):
                    sources.append(client)
    if (len(rlist) != len(reachable)):
        if debug_print:
            print('')
            print(reachable)
            print(rlist)
        raise ValueError('graph    contains    cycles')
    return rlist