def MostFreqToken(field_src, N, min_sample_size):
    """
    It will return the ids of the N most frequent sub-words.
    ----------------
    Parameters:

    field_src: torchtext.legacy.data.Field
        This is the vocab class by Pytorch
    N: int
        The ids of the N most frequent sub-words will be returned
    min_sample_size: int
        The minimum required frequency. The least frequent tokens of N should be larger than or equal to min_sample_size
    """
    sorted_vocab={k: v for k, v in sorted(field_src.vocab.freqs.items(), key=lambda item: item[1],reverse=True)}
    frequent_vocab=[]
    frequent_ids=[]
    for count, (this_vocab, freq) in enumerate(sorted_vocab.items()):
        if count < N:
            frequent_vocab.append(this_vocab)
        else:
            break
        assert freq >= min_sample_size, "The number of frequency should be larger than the minimum required sample size"
    for this_vocab in frequent_vocab:
        frequent_ids.append(field_src.vocab.stoi[this_vocab])
    return frequent_ids