code: def _bm25_weight(ui_mat):
      """Weight the matrix with BM25 algorithm"""
      K1 = 1.2
      B = 0.8
  
      X = coo_matrix(ui_mat)
      X.data = np.ones_like(X.data)
  
      N = float(X.shape[0])
      idf = np.log(N / np.bincount(X.col))
  
      # calculate length_norm per document (user)
      row_sums = np.ravel(X.sum(axis=1))
      average_length = row_sums.mean()
      length_norm = (1.0 - B) + B * row_sums / average_length
  
      # bm25 weights
      weights = (K1 + 1.0) / (K1 * length_norm[X.row] + X.data) * idf[
          X.col
      ] + 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 4 for calling a global function with example usage: _bm25_weight(ui_mat) and returns: weights