code: def dense_to_sparse(x, ignore_value=None, name=None):
      """Converts dense `Tensor` to `SparseTensor`, dropping `ignore_value` cells.
  
      Args:
        x: A `Tensor`.
        ignore_value: Entries in `x` equal to this value will be
          absent from the return `SparseTensor`. If `None`, default value of
          `x` dtype will be used (e.g. '' for `str`, 0 for `int`).
        name: Python `str` prefix for ops created by this function.
  
      Returns:
        sparse_x: A `tf.SparseTensor` with the same shape as `x`.
  
      Raises:
        ValueError: when `x`'s rank is `None`.
      """
      # Copied (with modifications) from:
      # tensorflow/contrib/layers/python/ops/sparse_ops.py.
      with tf.name_scope(name or "dense_to_sparse"):
          x = tf.convert_to_tensor(x, name="x")
          if ignore_value is None:
              if dtype_util.base_dtype(x.dtype) == tf.string:
                  # Exception due to TF strings are converted to numpy objects by default.
                  ignore_value = ""
              else:
                  ignore_value = dtype_util.as_numpy_dtype(x.dtype)(0)
              ignore_value = tf.cast(
                  ignore_value, x.dtype, name="ignore_value"
              )
          indices = tf.where(
              tf.not_equal(x, ignore_value), name="indices"
          )
          return tf.SparseTensor(
              indices=indices,
              values=tf.gather_nd(x, indices, name="values"),
              dense_shape=tf.shape(
                  x, out_type=tf.int64, name="dense_shape"
              ),
          )
  
label_desc: Use image node_id 1 for calling a global function with example usage: dense_to_sparse(x, ignore_value, name) and returns: tf