code: def test_dice_batch_size_greater_than_one(self):
      # test for Github issue #22: need to take mean per-image before
      # averaging Dice of ~1 and ~0.16, should get dice ~ 1 - 0.5816
      with self.cached_session():
          # predictions ~ [1, 0, 0]; [0, 0, 1]; [0, .5, .5]; [.333, .333, .333]
          predictions_numpy = np.array(
              [[[10.0, 0, 0], [0, 0, 10]], [[-10, 0, 0], [0, 0, 0]]]
          ).reshape([2, 2, 1, 1, 3])
          labels_numpy = np.array([[[0, 2]], [[0, 1]]]).reshape(
              [2, 2, 1, 1, 1]
          )
  
          predicted = tf.constant(
              predictions_numpy, dtype=tf.float32, name="predicted"
          )
          labels = tf.constant(
              labels_numpy, dtype=tf.int64, name="labels"
          )
  
          test_loss_func = LossFunction(3, loss_type="Dice")
          one_minus_dice_score = test_loss_func(predicted, labels)
  
          self.assertAllClose(
              one_minus_dice_score.eval(), 1 - 0.5816, 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 4 for calling the DiceTest obj's underlying member method code with example usage: obj.test_dice_batch_size_greater_than_one() without return types