<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Sparse Tensors
Step1:  Sparse Tensor Representation & Conversion
Q1. Convert tensor x into a SparseTensor.
Step2:  Q2. Investigate the dtype, indices, dense_shape and values of the SparseTensor sp in Q1.
Step3:  Q3. Let's write a custom function that converts a SparseTensor to Tensor. Complete it.
Step4:  Q4. Convert the SparseTensor sp to a Tensor using tf.sparse_to_dense.
Step5:  Q5. Convert the SparseTensor sp to a Tensor using tf.sparse_tensor_to_dense.
<ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import tensorflow as tf
import numpy as np
from datetime import date
date.today()
author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises"
tf.__version__
np.__version__
sess = tf.InteractiveSession()
Explanation: Sparse Tensors
End of explanation
x = tf.constant([[1, 0, 0, 0],
                 [0, 0, 2, 0],
                 [0, 0, 0, 0]], dtype=tf.int32)
sp = ...
print(sp.eval())
Explanation: Sparse Tensor Representation & Conversion
Q1. Convert tensor x into a SparseTensor.
End of explanation
print("dtype:", ...)
print("indices:", ...)
print("dense_shape:", ...)
print("values:", ...)
Explanation: Q2. Investigate the dtype, indices, dense_shape and values of the SparseTensor sp in Q1.
End of explanation
def dense_to_sparse(tensor):
    indices = tf.where(tf.not_equal(tensor, 0))
    return tf.SparseTensor(indices=indices,
                           values=...,  # for zero-based index
                           dense_shape=tf.to_int64(tf.shape(tensor)))
# Test
print(dense_to_sparse(x).eval())
Explanation: Q3. Let's write a custom function that converts a SparseTensor to Tensor. Complete it.
End of explanation
output = ...
print(output.eval())
print("Check if this is identical with x:\n", x.eval())
Explanation: Q4. Convert the SparseTensor sp to a Tensor using tf.sparse_to_dense.
End of explanation
output = ...
print(output.eval())
print("Check if this is identical with x:\n", x.eval())
Explanation: Q5. Convert the SparseTensor sp to a Tensor using tf.sparse_tensor_to_dense.
End of explanation
<END_TASK>