For this Question: Given an array of integers that might contain duplicates, return all possible subsets.

Note:
Elements in a subset must be in non-descending order.
The solution set must not contain duplicate subsets.
The subsets must be sorted lexicographically.First line of input contains number of testcases T. For each testcase, there will be two line of input, first of which contains N and next contains N space seperated integers. Every test case has two lines. First line is N, size of array.

Constraints:
1 <= T <= 500
1 <= N <= 12
1 <= x <= 9One line per test case, every subset enclosed in () and in every set intergers should be space seperated.(See example)Sample Input:
2
3
1 2 2
4
1 2 3 3

Sample Output:
()(1)(1 2)(1 2 2)(2)(2 2)
()(1)(1 2)(1 2 3)(1 2 3 3)(1 3)(1 3 3)(2)(2 3)(2 3 3)(3)(3 3)

Explanation:
Testcase 1: Subsets are
[
[],
[1],
[1,2],
[1,2,2],
[2],
[2, 2]
], I have written this Solution Code: import re
def subsetsWithDup(nums):
        ret = []
        dfs(sorted(nums), [], ret)
        return ret
    
def dfs(nums, path, ret):
        ret.append(path)
        for i in range(len(nums)):
            if i > 0 and nums[i] == nums[i-1]:
                continue
            dfs(nums[i+1:], path+[nums[i]], ret)

t = int(input())
while(t>0):
    n = int(input())
    nums = [int(i) for i in input().strip().split(" ")]
    for i in subsetsWithDup(nums):
        print(str(tuple(i)).replace(",",""),end="")
    t-=1
    print(), In this Programming Language: Python, Now tell me if this Code is compilable or not?