in basic_pitch/data/tf_example_deserialization.py [0:0]
def sparse2dense(values: tf.Tensor, indices: tf.Tensor, dense_shape: tf.Tensor) -> tf.Tensor:
"""converts sparse tensor representation to dense vector"""
if tf.rank(indices) != 2 and tf.size(indices) == 0:
indices = tf.zeros([0, 1], dtype=indices.dtype)
tf.assert_rank(indices, 2)
tf.assert_rank(values, 1)
tf.assert_rank(dense_shape, 1)
sp = tf.SparseTensor(indices=indices, values=values, dense_shape=dense_shape)
return tf.sparse.to_dense(sp, validate_indices=False)