def powerset(l):
    """
    Generates all subsets of list `l` (as tuples).

    Example
    -------
    >>> from pgmpy.utils.mathext import powerset
    >>> list(powerset([1,2,3]))
    [(), (1,), (2,), (3,), (1,2), (1,3), (2,3), (1,2,3)]
    """
    return chain.from_iterable(combinations(l, r) for r in range(len(l)+1))
Generates all subsets of list `l` (as tuples).

    Example
    -------
    >>> from pgmpy.utils.mathext import powerset
    >>> list(powerset([1,2,3]))
    [(), (1,), (2,), (3,), (1,2), (1,3), (2,3), (1,2,3)]