code: def test_cross_entropy_value_weight(self):
      with self.cached_session():
          weights = tf.constant(
              [[1], [2]], dtype=tf.float32, name="weights"
          )
          predicted = tf.constant(
              [[0, 1], [2, 0]], dtype=tf.float32, name="predicted"
          )
          labels = tf.constant(
              [[1], [0]], dtype=tf.int64, name="labels"
          )
          predicted, labels, weights = [
              tf.expand_dims(x, axis=0)
              for x in (predicted, labels, weights)
          ]
  
          test_loss_func = LossFunction(2, loss_type="CrossEntropy")
          computed_cross_entropy = test_loss_func(
              predicted, labels, weights
          )
          self.assertAlmostEqual(
              computed_cross_entropy.eval(),
              -0.5
              * (
                  2.0 / 3.0 * np.log(np.e / (1 + np.e))
                  + 4.0 / 3.0 * np.log(np.e**2 / (1 + np.e**2))
              ),
          )
  
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 2 for calling the CrossEntropyTests obj's underlying member method code with example usage: obj.test_cross_entropy_value_weight() without return types