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: import warnings
  from numbers import Integral, Real
  import numpy
  from scipy.sparse import coo_matrix, csr_matrix
  from scipy.special import xlogy
  from ..exceptions import UndefinedMetricWarning
  from ..preprocessing import LabelBinarizer, LabelEncoder
  from ..utils import assert_all_finite, check_array, check_consistent_length, column_or_1d
  from ..utils._param_validation import Interval, Options, StrOptions, validate_params
  from ..utils.extmath import _nanaverage
  from ..utils.multiclass import type_of_target, unique_labels
  from ..utils.sparsefuncs import count_nonzero
  from ..utils.validation import _check_pos_label_consistency, _num_samples
label_desc: Use image node_id 3 for calling a global function with example usage: _weighted_sum(sample_score, sample_weight, normalize) and returns: np, np, sample_score