code: def test_sparse(self):
      const_float = tf.constant(3.0, dtype=tf.float32)
      sparse_float = tf.SparseTensor(
          tf.constant([[111], [232]], tf.int64),
          tf.constant([23.4, -43.2], tf.float32),
          tf.constant([500], tf.int64),
      )
      self.assertIs(
          tf.float32,
          dtype_util.assert_same_float_dtype(
              [sparse_float], tf.float32
          ),
      )
      self.assertRaises(
          ValueError,
          dtype_util.assert_same_float_dtype,
          [sparse_float],
          tf.int32,
      )
      self.assertRaises(
          ValueError,
          dtype_util.assert_same_float_dtype,
          [const_float, None, sparse_float],
          tf.float64,
      )
  
      self.assertIs(
          tf.float32,
          dtype_util.assert_same_float_dtype(
              [const_float, sparse_float]
          ),
      )
      self.assertIs(
          tf.float32,
          dtype_util.assert_same_float_dtype(
              [const_float, sparse_float], tf.float32
          ),
      )
  
      const_int = tf.constant(3, dtype=tf.int32)
      self.assertRaises(
          ValueError,
          dtype_util.assert_same_float_dtype,
          [sparse_float, const_int],
      )
      self.assertRaises(
          ValueError,
          dtype_util.assert_same_float_dtype,
          [sparse_float, const_int],
          tf.int32,
      )
      self.assertRaises(
          ValueError,
          dtype_util.assert_same_float_dtype,
          [sparse_float, const_int],
          tf.float32,
      )
      self.assertRaises(
          ValueError, dtype_util.assert_same_float_dtype, [const_int]
      )
  
imports: import dataclasses
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 2 for calling the FloatDTypeTest obj's underlying member method code with example usage: obj.test_sparse() without return types