code: def sparse_const(matrix):
      indices = []
      values = []
      for i, row in enumerate(matrix):
          for j, val in enumerate(row):
              indices.append([i, j])
              values.append(val)
      shape = (
          [len(matrix), max(len(row) for row in matrix)]
          if matrix
          else [0, 0]
      )
      if not values:
          indices = np.zeros([0, 2], dtype=np.int64)
          values = np.zeros([0], dtype=np.int64)
      return sparse_tensor.SparseTensorValue(indices, values, shape)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_ragged_array_ops
  from tensorflow.python.ops import sparse_ops
  from tensorflow.python.ops.ragged import ragged_array_ops
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 1 for calling a global function with example usage: sparse_const(matrix) and returns: sparse_tensor