code: def get_tfidf_matrix(cnts):
      """
      Convert the word count matrix into tfidf one.
  
      tfidf = log(tf + 1) * log((N - Nt + 0.5) / (Nt + 0.5))
      * tf = term frequency in document
      * N = number of documents
      * Nt = number of occurrences of term in all documents
      """
      Nt = get_doc_freqs(cnts)
      idfs = np.log((cnts.shape[1] - Nt + 0.5) / (Nt + 0.5))
      idfs[idfs < 0] = 0
      idfs = sp.diags(idfs, 0)
      tfs = cnts.log1p()
      tfidfs = idfs.dot(tfs)
  
      return tfidfs
  
imports: import numpy
  import scipy.sparse
  import math
  from multiprocessing import Pool
  from multiprocessing.util import Finalize
  from functools import partial
  from collections import Counter
  from .None import utils
  from .doc_db import DocDB
  from .None import tokenizers
  import parlai.utils.logging
label_desc: Use image node_id 8 for calling a global function with example usage: get_tfidf_matrix(cnts) and returns: tfidfs