def idfs(corpus):
    """ Compute IDF
    Args:
        corpus (RDD): input corpus
    Returns:
        RDD: a RDD of (token, IDF value)
    """

    N = corpus.count()

    # The result of the next line will be a list with distinct tokens...
    unique_tokens = corpus.flatMap(lambda x: list(set(x)))  # No more records! FLATMAP --> unique_tokens is ONE SINGLE LIST
    token_count_pair_tuple = unique_tokens.map(lambda x: (x, 1))  # every element in the list will become a pair!
    token_sum_pair_tuple = token_count_pair_tuple.reduceByKey(lambda a, b: a + b)  # same elements in lists are aggregated
    return token_sum_pair_tuple.map(lambda x: (x[0], float(N) / x[1]))