Given a list of integers, write an algorithm to find duplicates.
Return a list containing each duplicated value once, in the order that its repetition is first detected. The input is a list of integers, and the output is a list of integers. Implement def find_duplicates(nums): without modifying the input list.
def find_duplicates(nums):