'Enumerate the partitions of a multiset.
Examples
>>> from sympy.utilities.enumerative import list_visitor
>>> from sympy.utilities.enumerative import MultisetPartitionTraverser
>>> m = MultisetPartitionTraverser()
>>> states = m.enum_all([2,2])
>>> list(list_visitor(state, \'ab\') for state in states)
[[[\'a\', \'a\', \'b\', \'b\']],
[[\'a\', \'a\', \'b\'], [\'b\']],
[[\'a\', \'a\'], [\'b\', \'b\']],
[[\'a\', \'a\'], [\'b\'], [\'b\']],
[[\'a\', \'b\', \'b\'], [\'a\']],
[[\'a\', \'b\'], [\'a\', \'b\']],
[[\'a\', \'b\'], [\'a\'], [\'b\']],
[[\'a\'], [\'a\'], [\'b\', \'b\']],
[[\'a\'], [\'a\'], [\'b\'], [\'b\']]]
See also
multiset_partitions_taocp():
which provides the same result as this method, but is
about twice as fast.  Hence, enum_all is primarily useful
for testing.  Also see the function for a discussion of
states and visitors.'

def enum_all(self, multiplicities):

    self._initialize_enumeration(multiplicities)
    while True:
        while self.spread_part_multiplicity():
            pass
        state = [self.f, self.lpart, self.pstack]
        (yield state)
        while (not self.decrement_part(self.top_part())):
            if (self.lpart == 0):
                return
            self.lpart -= 1
