code: def _idf_weight(ui_mat):
      """Weight the matrix Inverse Document (Item) Frequency"""
      X = coo_matrix(ui_mat)
  
      # calculate IDF
      N = float(X.shape[0])
      idf = np.log(N / np.bincount(X.col))
  
      weights = idf[ui_mat.indices] + EPS
      return weights
  
imports: import multiprocessing
  import numpy
  from scipy.sparse import csr_matrix, coo_matrix
  from ..recommender import Recommender
  from ...exception import ScoreException
  from ...utils import get_rng
  from ...utils.fast_sparse_funcs import inplace_csr_row_normalize_l2
  from .similarity import compute_similarity, compute_score, compute_score_single
label_desc: Use image node_id 3 for calling a global function with example usage: _idf_weight(ui_mat) and returns: weights