def get_dependencies(dsk, key=None, task=no_default, as_list=False):
    """Get the immediate tasks on which this task depends.

    Examples
    --------
    >>> from flash.core.serve.dag.utils_test import add, inc
    >>> dsk = {'x': 1,
    ...        'y': (inc, 'x'),
    ...        'z': (add, 'x', 'y'),
    ...        'w': (inc, 'z'),
    ...        'a': (add, (inc, 'x'), 1)}
    >>> get_dependencies(dsk, 'x')
    set()
    >>> get_dependencies(dsk, 'y')
    {'x'}
    >>> sorted(get_dependencies(dsk, 'z'))
    ['x', 'y']
    >>> get_dependencies(dsk, 'w')  # Only direct dependencies
    {'z'}
    >>> get_dependencies(dsk, 'a')  # Ignore non-keys
    {'x'}
    >>> get_dependencies(dsk, task=(inc, 'x'))  # provide tasks directly
    {'x'}

    """
    if key is not None:
        arg = dsk[key]
    elif task is not no_default:
        arg = task
    else:
        raise ValueError("Provide either key or task")

    result = []
    work = [arg]

    while work:
        new_work = []
        for w in work:
            typ = type(w)
            if typ is tuple and w and callable(w[0]):  # istask(w)
                new_work.extend(w[1:])
            elif typ is list:
                new_work.extend(w)
            elif typ is dict:
                new_work.extend(w.values())
            else:
                try:
                    if w in dsk:
                        result.append(w)
                except TypeError:  # not hashable
                    pass
        work = new_work

    return result if as_list else set(result)
Get the immediate tasks on which this task depends.

    Examples
    --------
    >>> from flash.core.serve.dag.utils_test import add, inc
    >>> dsk = {'x': 1,
    ...        'y': (inc, 'x'),
    ...        'z': (add, 'x', 'y'),
    ...        'w': (inc, 'z'),
    ...        'a': (add, (inc, 'x'), 1)}
    >>> get_dependencies(dsk, 'x')
    set()
    >>> get_dependencies(dsk, 'y')
    {'x'}
    >>> sorted(get_dependencies(dsk, 'z'))
    ['x', 'y']
    >>> get_dependencies(dsk, 'w')  # Only direct dependencies
    {'z'}
    >>> get_dependencies(dsk, 'a')  # Ignore non-keys
    {'x'}
    >>> get_dependencies(dsk, task=(inc, 'x'))  # provide tasks directly
    {'x'}

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