code: def sp_matrix_to_sp_tensor(x):
      """
      Converts a Scipy sparse matrix to a SparseTensor.
      The indices of the output are reordered in the canonical row-major ordering, and
      duplicate entries are summed together (which is the default behaviour of Scipy).
  
      :param x: a Scipy sparse matrix.
      :return: a SparseTensor.
      """
      if len(x.shape) != 2:
          raise ValueError("x must have rank 2")
      row, col, values = sp.find(x)
      out = tf.SparseTensor(
          indices=np.array([row, col]).T,
          values=values,
          dense_shape=x.shape,
      )
      return tf.sparse.reorder(out)
  
imports: import numpy
  import tensorflow
  from scipy import sparse
label_desc: Use image node_id 3 for calling a global function with example usage: sp_matrix_to_sp_tensor(x) and returns: tf