<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def powerset(iterable, nonempty=False, reverse=False):
 """Generate the power set of an iterable. Args: iterable (Iterable):
 The iterable from which to generate the power set. Keyword Args: nonempty (boolean):
 If True, don't include the empty set. reverse (boolean):
 If True, reverse the order of the powerset. Returns: Iterable: An iterator over the power set. Example: [(), (0,), (1,), (0, 1)] [(0,), (1,), (0, 1)] [(1, 0), (1,), (0,)] """

    iterable = list(iterable)

    if nonempty:  # Don't include 0-length subsets
        start = 1
    else:
        start = 0

    seq_sizes = range(start, len(iterable) + 1)

    if reverse:
        seq_sizes = reversed(seq_sizes)
        iterable.reverse()

    return chain.from_iterable(combinations(iterable, r) for r in seq_sizes)