Walk me through profiling and optimizing a hot function.
Implement an optimized version of the function below. Given a list of integers, return the sum of the squares of distinct values, preserving no ordering requirement. Explain which profiling evidence would justify the optimization and provide the function implementation.
Function: def sum_unique_squares(nums):
Input: A list of integers. Output: An integer equal to the sum of each distinct value squared.
def sum_unique_squares(nums):