tff.analytics.data_processing.get_top_elements

Gets the top max_user_contribution unique words from the input dataset.

The input dataset must yield batched 1-d tensors. This function reads each coordinate of the tensor as an individual element and caps the total number of elements to return. Note that the returned set of top words will not necessarily be sorted.

dataset A tf.data.Dataset to extract top elements from.
max_user_contribution The maximum number of elements to keep.

A rank-1 Tensor containing the top max_user_contribution unique elements of the input dataset. If the total number of unique words is less than or equal to max_user_contribution, returns the list of all unique elements.