code: def _weighted_sum(sample_score, sample_weight, normalize=False):
      if normalize:
          return np.average(sample_score, weights=sample_weight)
      elif sample_weight is not None:
          return np.dot(sample_score, sample_weight)
      else:
          return sample_score.sum()
  
imports: from __future__ import division
  import warnings
  import numpy
  from scipy.sparse import coo_matrix
  from scipy.sparse import csr_matrix
  from ..preprocessing import LabelBinarizer, label_binarize
  from ..preprocessing import LabelEncoder
  from ..utils import assert_all_finite
  from ..utils import check_array
  from ..utils import check_consistent_length
  from ..utils import column_or_1d
  from ..utils.multiclass import unique_labels
  from ..utils.multiclass import type_of_target
  from ..utils.validation import _num_samples
  from ..utils.sparsefuncs import count_nonzero
  from ..utils.fixes import bincount
  from ..exceptions import UndefinedMetricWarning
label_desc: Use image node_id 2 for calling a global function with example usage: _weighted_sum(sample_score, sample_weight, normalize) and returns: np, np, sample_score