code: def testBadSparseTensorRank(self):
      st1 = sparse_tensor.SparseTensor(
          indices=[[0]], values=[0], dense_shape=[3]
      )
      self.assertRaisesRegex(
          ValueError,
          r"rank\(st_input\) must be 2",
          RaggedTensor.from_sparse,
          st1,
      )
  
      st2 = sparse_tensor.SparseTensor(
          indices=[[0, 0, 0]], values=[0], dense_shape=[3, 3, 3]
      )
      self.assertRaisesRegex(
          ValueError,
          r"rank\(st_input\) must be 2",
          RaggedTensor.from_sparse,
          st2,
      )
  
      if not context.executing_eagerly():
          st3 = sparse_tensor.SparseTensor(
              indices=array_ops.placeholder(dtypes.int64),
              values=[0],
              dense_shape=array_ops.placeholder(dtypes.int64),
          )
          self.assertRaisesRegex(
              ValueError,
              r"rank\(st_input\) must be 2",
              RaggedTensor.from_sparse,
              st3,
          )
  
file_path: tensorflow-upstream/tensorflow/python/ops/ragged/ragged_from_sparse_op_test.py
imports: from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops.ragged.ragged_tensor import RaggedTensor
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 3 for calling the RaggedTensorToSparseOpTest obj's underlying member method code with example usage: obj.testBadSparseTensorRank() without return types