code: def sample_weighted(mat):
      """
      Candidate sampling function for use with :py:func:`neg_sample`.
      It samples items proportionally to their popularity.
      """
      j = np.random.randint(0, mat.nnz)
      return mat.colinds[j]
  
imports: import numpy
  from numba import njit
label_desc: Use image node_id 2 for calling a global function with example usage: sample_weighted(mat) and returns: mat