code: def test_upper_bound_has_correct_outputs_and_gradients(
      self, gradient
  ):
      inputs = tf.constant([-1, 1], dtype=tf.float32)
      with tf.GradientTape(persistent=True) as tape:
          tape.watch(inputs)
          outputs = math_ops.upper_bound(inputs, 0, gradient=gradient)
      pgrads = tape.gradient(outputs, inputs, tf.ones_like(inputs))
      ngrads = tape.gradient(outputs, inputs, -tf.ones_like(inputs))
      self.assertAllEqual(outputs, [-1, 0])
      if gradient == "disconnected":
          self.assertAllEqual(pgrads, [1, 0])
          self.assertAllEqual(ngrads, [-1, 0])
      elif gradient == "identity":
          self.assertAllEqual(pgrads, [1, 1])
          self.assertAllEqual(ngrads, [-1, -1])
      else:
          self.assertAllEqual(pgrads, [1, 1])
          self.assertAllEqual(ngrads, [-1, 0])
  
file_path: compression/tensorflow_compression/python/ops/math_ops_test.py
imports: from absl.testing import parameterized
  import scipy.stats
  import tensorflow
  from tensorflow_compression.python.ops import math_ops
  from tensorflow_compression.python.ops import round_ops
label_desc: Use image node_id 1 for calling the MathTest obj's underlying member method code with example usage: obj.test_upper_bound_has_correct_outputs_and_gradients(gradient) without return types