Distinct orderings with repeats

Write unique_permutations(items) that returns every distinct ordering of a list that may contain repeated values. Order of the output does not matter.

unique_permutations([1, 1, 2])  ->  [[1, 1, 2], [1, 2, 1], [2, 1, 1]]
unique_permutations([])         ->  [[]]

The point is to practise the duplicate-skip rule in the permutation template: at each slot, do not place a value equal to one you already tried in that slot.

def unique_permutations(items):
    ...