docstr: Test a dataset based on slices of a `tf.sparse.SparseTensor`.
docstr_tok: ["Test","a","dataset","based","on","slices","of","a","`","tf.sparse.SparseTensor","`","."]
code: def testFromSparseTensorSlices(self, slices):
      """Test a dataset based on slices of a `tf.sparse.SparseTensor`."""
      st = array_ops.sparse_placeholder(dtypes.float64)
      iterator = dataset_ops.make_initializable_iterator(
          dataset_ops.Dataset.from_sparse_tensor_slices(st)
      )
      init_op = iterator.initializer
      get_next = sparse_tensor.SparseTensor(*iterator.get_next())
  
      with self.cached_session() as sess:
          # Test with sparse tensor in the appropriate order.
          # pylint: disable=g-complex-comprehension
          indices = np.array(
              [
                  [i, j]
                  for i in range(len(slices))
                  for j in range(len(slices[i]))
              ]
          )
          values = np.array([val for s in slices for val in s])
          # pylint: enable=g-complex-comprehension
          dense_shape = np.array(
              [len(slices), max(len(s) for s in slices) + 1]
          )
          sparse_feed = sparse_tensor.SparseTensorValue(
              indices, values, dense_shape
          )
          sess.run(init_op, feed_dict={st: sparse_feed})
          for i, s in enumerate(slices):
              results = sess.run(get_next)
              self.assertAllEqual(s, results.values)
              expected_indices = np.array(
                  [[j] for j in range(len(slices[i]))]
              ).reshape([-1, 1])
              self.assertAllEqual(expected_indices, results.indices)
              self.assertAllEqual(dense_shape[1:], results.dense_shape)
          with self.assertRaises(errors.OutOfRangeError):
              sess.run(get_next)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.kernel_tests import checkpoint_test_base
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the FromSparseTensorSlicesTest obj's underlying member method code with example usage: obj.testFromSparseTensorSlices(slices) without return types