class_docstr: A Loss that adds up a weighted sum of other losses.
class_docstr_tok: ["A","Loss","that","adds","up","a","weighted","sum","of","other","losses","."]
code: def fprop(self, x, y, **kwargs):
      weights, loss_objects = safe_zip(*self.terms)
      for weight in weights:
          if isinstance(weight, float):
              continue
          if hasattr(weight, "ndim"):
              assert weight.ndim == 0
              continue
          raise TypeError(
              "weight of %s is not a type that this function "
              "knows it can accept yet" % str(weight)
          )
      losses = [loss.fprop(x, y, **kwargs) for loss in loss_objects]
      for loss, loss_object in safe_zip(losses, loss_objects):
          if len(loss.get_shape()) > 0:
              raise ValueError(
                  "%s.fprop returned a non-scalar value"
                  % str(loss_object)
              )
      terms = [
          weight * loss for weight, loss in safe_zip(weights, losses)
      ]
  
      return tf.add_n(terms)
  
imports: import copy
  import json
  import os
  import warnings
  import numpy
  import tensorflow
  from cleverhans.attacks import Attack
  from cleverhans.compat import softmax_cross_entropy_with_logits
  from cleverhans.model import Model
  from cleverhans.utils import safe_zip
label_desc: Use image node_id 2 for calling the WeightedSum obj's underlying member method code with example usage: obj.fprop(x, y) and returns: tf