code: def count_tf(tokens_stream):
      
      tf = defaultdict(int)
      for tokens in tokens_stream:
          for token in tokens:
              tf[token] += 1
      return tf
docs: Count term frequencies for a single file.