<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def count_tf(tokens_stream):
 """ Count term frequencies for a single file. """

    tf = defaultdict(int)
    for tokens in tokens_stream:
        for token in tokens:
            tf[token] += 1
    return tf