code: def reduce_weighted_values(
      values,
      sample_weight=None,
      mask=None,
      reduction="sum_over_batch_size",
      dtype=None,
  ):
      reduction = standardize_reduction(reduction)
  
      values = ops.convert_to_tensor(values, dtype=dtype)
      if sample_weight is not None:
          sample_weight = ops.convert_to_tensor(
              sample_weight, dtype=dtype
          )
      if mask is not None:
          mask = ops.convert_to_tensor(mask, dtype=dtype)
  
      # Merge mask and sample weight into sample weight.
      sample_weight = apply_mask(
          sample_weight, mask, dtype=values.dtype, reduction=reduction
      )
  
      if sample_weight is not None:
          sample_weight = ops.cast(sample_weight, values.dtype)
          # Update dimensions of `sample_weight` to match `losses`.
          values, sample_weight = squeeze_to_same_rank(
              values, sample_weight
          )
          values = values * sample_weight
  
      # Apply reduction function to the individual weighted losses.
      loss = reduce_values(values, reduction)
      return loss
  
file_path: keras/keras/losses/loss.py
imports: import tree
  from keras import backend
  from keras import ops
  from keras.api_export import keras_export
  from keras.utils.naming import auto_name
label_desc: Use image node_id 4 for calling a global function with example usage: reduce_weighted_values(values, sample_weight, mask, reduction, dtype) and returns: loss