def random_powerset(iterable):
    s = list(iterable)
lengths = list(range(len(s) + 1))
shuffle(lengths)
return chain.from_iterable(combinations(s, r) for r in lengths if not
    shuffle(s))
Randomize chain from itertools