code: def _calc_row_means(mat, densities):
      means = []
      for i in range(mat.shape[0]):
          try:
              means.append(
                  np.average(mat[i, :], weights=densities[i, :])
              )
          except ZeroDivisionError:  # pragma: no cover
              means.append(0)
      return means
  
imports: import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: _calc_row_means(mat, densities) and returns: means