code: def test_missing_class(self):
      with self.cached_session():
          predicted = tf.constant(
              [[0, 0, 1], [1, 0, 0]], dtype=tf.float32, name="predicted"
          )
          labels = tf.constant([2, 0], dtype=tf.int32)
  
          predicted, labels = [
              tf.expand_dims(x, axis=0) for x in (predicted, labels)
          ]
  
          for loss_func in (
              "Dice",
              "Dice_NS",
              "Dice_Dense",
              "Dice_Dense_NS",
          ):
              test_loss_func = LossFunction(
                  3, loss_type=loss_func, softmax=False
              )
              if "Dense" in loss_func:
                  loss_value = test_loss_func(
                      predicted, tf.one_hot(labels, 3)
                  )
              else:
                  loss_value = test_loss_func(predicted, labels)
  
              # softmax of zero, Dice loss of -1, so sum \approx -1
              self.assertAllClose(loss_value.eval(), 0.0, atol=1e-4)
  
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 1 for calling the DiceWithMissingClass obj's underlying member method code with example usage: obj.test_missing_class() without return types