class_docstr: Compute the (weighted) sum of the given values.
  
  For example, if `values` is `[1, 3, 5, 7]` then their sum is 16.
  If `sample_weight` was specified as `[1, 1, 0, 0]` then the sum would be 4.
  
  This metric creates one variable, `total`.
  This is ultimately returned as the sum value.
  
  Args:
      name: (Optional) string name of the metric instance.
      dtype: (Optional) data type of the metric result.
  
  Example:
  
  >>> m = metrics.Sum()
  >>> m.update_state([1, 3, 5, 7])
  >>> m.result()
  16.0
  
  >>> m = metrics.Sum()
  >>> m.update_state([1, 3, 5, 7], sample_weight=[1, 1, 0, 0])
  >>> m.result()
  4.0
class_docstr_tok: ["Compute","the","(","weighted",")","sum","of","the","given","values",".","For","example",",","if","`","values","`","is","`","[","1",",","3",",","5",",","7","]","`","then","their","sum","is","16",".","If","`","sample_weight","`","was","specified","as","`","[","1",",","1",",","0",",","0","]","`","then","the","sum","would","be","4",".","This","metric","creates","one","variable",",","`","total","`",".","This","is","ultimately","returned","as","the","sum","value",".","Args",":","name",":","(","Optional",")","string","name","of","the","metric","instance",".","dtype",":","(","Optional",")","data","type","of","the","metric","result",".","Example",":",">",">",">","m","=","metrics.Sum","(",")",">",">",">","m.update_state","(","[","1",",","3",",","5",",","7","]",")",">",">",">","m.result","(",")","16.0",">",">",">","m","=","metrics.Sum","(",")",">",">",">","m.update_state","(","[","1",",","3",",","5",",","7","]",",","sample_weight=","[","1",",","1",",","0",",","0","]",")",">",">",">","m.result","(",")","4.0"]
code: def update_state(self, values, sample_weight=None):
      values, _ = reduce_to_samplewise_values(
          values, sample_weight, reduce_fn=ops.sum, dtype=self.dtype
      )
      self.total.assign(self.total + ops.sum(values))
  
imports: from keras import backend
  from keras import initializers
  from keras import losses
  from keras import ops
  from keras.api_export import keras_export
  from keras.metrics.metric import Metric
  from keras.saving import serialization_lib
label_desc: Use image node_id 2 for calling the Sum obj's underlying member method code with example usage: obj.update_state(values, sample_weight) without return types