def functions_of(task):
    """Set of functions contained within nested task.

    Examples
    --------
    >>> from flash.core.serve.dag.utils_test import add, inc, mul
    >>> task = (add, (mul, 1, 2), (inc, 3))
    >>> sorted(functions_of(task), key=str)  # doctest: +ELLIPSIS
    [<function add at ...>, <function inc at ...>, <function mul at ...>]

    """
    funcs = set()

    work = [task]
    sequence_types = {list, tuple}

    while work:
        new_work = []
        for task in work:
            if type(task) in sequence_types:
                if istask(task):
                    funcs.add(unwrap_partial(task[0]))
                    new_work.extend(task[1:])
                else:
                    new_work.extend(task)
        work = new_work

    return funcs
Set of functions contained within nested task.

    Examples
    --------
    >>> from flash.core.serve.dag.utils_test import add, inc, mul
    >>> task = (add, (mul, 1, 2), (inc, 3))
    >>> sorted(functions_of(task), key=str)  # doctest: +ELLIPSIS
    [<function add at ...>, <function inc at ...>, <function mul at ...>]

    
src/flash/core/serve/dag/optimization.py