code: def tfidf_weight(X):
      """Weights a Sparse Matrix by TF-IDF Weighted"""
      X = coo_matrix(X)
  
      # calculate IDF
      N = float(X.shape[0])
      idf = log(N) - log1p(bincount(X.col))
  
      # apply TF-IDF adjustment
      X.data = sqrt(X.data) * idf[X.col]
      return X
  
imports: import numpy
  from numpy import bincount, log, log1p, sqrt
  from scipy.sparse import coo_matrix, csr_matrix
  from ._nearest_neighbours import NearestNeighboursScorer, all_pairs_knn
  from .recommender_base import RecommenderBase
  from .utils import _batch_call
label_desc: Use image node_id 1 for calling a global function with example usage: tfidf_weight(X) and returns: X