code: def test_soft_round_inverse_values_and_gradients_are_finite(
      self, alpha
  ):
      x = tf.linspace(
          -0.5, 0.5, 11
      )  # covers exact integers and half-integers
      with tf.GradientTape() as tape:
          tape.watch(x)
          y = round_ops.soft_round_inverse(x, alpha=alpha)
      dy = tape.gradient(y, x)
      self.assertAllEqual(
          tf.math.is_finite(y), tf.ones(x.shape, dtype=bool)
      )
      is_finite = tf.math.is_finite(dy)
      expected_finite = tf.ones(dy.shape, dtype=bool)
      if alpha > 15:
          # We allow non-finite values at 0 for large alphas, since the function
          # simply is extremely steep there.
          expected_finite = tf.tensor_scatter_nd_update(
              expected_finite, [[5]], [is_finite[5]]
          )
      self.assertAllEqual(is_finite, expected_finite)
  
file_path: compression/tensorflow_compression/python/ops/round_ops_test.py
imports: from absl.testing import parameterized
  import tensorflow
  from tensorflow_compression.python.ops import round_ops
label_desc: Use image node_id 8 for calling the SoftRoundTest obj's underlying member method code with example usage: obj.test_soft_round_inverse_values_and_gradients_are_finite(alpha) without return types