code: def _purify_row(mat, marg, densities, i):
      # Purify such that row i has mean 0.
      try:
          _mean = np.average(mat[i, :], weights=densities[i, :])
          marg[i] += _mean
          mat[i, :] -= _mean
      except ZeroDivisionError:  # pragma: no cover
          pass
      return mat, marg
  
imports: import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _purify_row(mat, marg, densities, i) and returns: mat,  marg