code: def test_dense_dice_vs_sparse(self):
      # regression test vs dense version
      with self.cached_session():
          predicted = tf.constant(
              [[2, 3], [9, 8], [0, 0], [1, 0]],
              dtype=tf.float32,
              name="predicted",
          )
          labels = tf.constant(
              [1, 0, 0, 0], dtype=tf.int64, name="labels"
          )
  
          predicted, labels = [
              tf.expand_dims(x, axis=0) for x in (predicted, labels)
          ]
  
          sparse_loss_func = LossFunction(2, loss_type="Dice")
          sparse_dice = sparse_loss_func(predicted, labels)
  
          one_hot = tf.one_hot(labels, axis=-1, depth=2)
          dense_loss_func = LossFunction(2, loss_type="Dice_Dense")
          dense_dice = dense_loss_func(predicted, one_hot)
  
          self.assertAllEqual(sparse_dice.eval(), dense_dice.eval())
  
imports: from __future__ import absolute_import, print_function
  import numpy
  import tensorflow
  from niftynet.layer.loss_segmentation import LossFunction, labels_to_one_hot
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 3 for calling the DiceDenseTest obj's underlying member method code with example usage: obj.test_dense_dice_vs_sparse() without return types