code: def test_dice_plus_non_zeros(self):
      with self.cached_session():
          predicted = tf.constant(
              [
                  [0, 9999, 9999],
                  [9999, 0, 0],
                  [0, 9999, 9999],
                  [9999, 0, 0],
              ],
              dtype=tf.float32,
              name="predicted",
          )
          labels = tf.constant(
              [2, 0, 1, 0], dtype=tf.int16, name="labels"
          )
          predicted, labels = [
              tf.expand_dims(x, axis=0) for x in (predicted, labels)
          ]
          test_loss_func = LossFunction(
              3, loss_type="DicePlusXEnt", softmax=False
          )
          loss_value = test_loss_func(predicted, labels)
          # cross-ent of mean(ln(2), 0, 0, ln(2)) = .5*ln(2)
          # Dice loss of -mean(1, .5, .5)=-2/3
          self.assertAllClose(
              loss_value.eval(), 0.5 * np.log(2) - 2.0 / 3.0, atol=1e-3
          )
  
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 DicePlusXEntTest obj's underlying member method code with example usage: obj.test_dice_plus_non_zeros() without return types