code: def precompute_idfs(wglobal, dfs, total_docs):
      """Pre-compute the inverse document frequency mapping for all terms.
  
      Parameters
      ----------
      wglobal : function
          Custom function for calculating the "global" weighting function.
          See for example the SMART alternatives under :func:`~gensim.models.tfidfmodel.smartirs_wglobal`.
      dfs : dict
          Dictionary mapping `term_id` into how many documents did that term appear in.
      total_docs : int
          Total number of documents.
  
      Returns
      -------
      dict of (int, float)
          Inverse document frequencies in the format `{term_id_1: idfs_1, term_id_2: idfs_2, ...}`.
  
      """
      # not strictly necessary and could be computed on the fly in TfidfModel__getitem__.
      # this method is here just to speed things up a little.
      return {
          termid: wglobal(df, total_docs) for termid, df in dfs.items()
      }
  
file_path: gensim/gensim/models/tfidfmodel.py
imports: import logging
  from functools import partial
  import re
  import numpy
  from gensim import interfaces, matutils, utils
  from gensim.utils import deprecated
label_desc: Use image node_id 3 for calling a global function with example usage: precompute_idfs(wglobal, dfs, total_docs) and returns: unknown