Describe an algorithm to create a list of pairs of integers where each pair's sum equals a given target value and the integers in the pair appear in an input list.
Implement def target_sum_pairs(nums, target):. Return each distinct value pair once, with the smaller value first, sorted lexicographically. A value may form a pair with itself only when it appears at least twice. Return an empty list when no pair exists.
def target_sum_pairs(nums, target):