Calculate frequency of tuples?

Let suppose I have a tensor of shape (N, M) where N is total number of tuples and M is total numbers in each tuple. I want to count how many unique tuples are and what is the frequency of each using gpu acceleration.