code: def cross_entropy_function(is_real, softness=0.1):
      def cross_entropy_op(pred, **kwargs):
          if is_real:
              target = (1.0 - softness) * tf.ones_like(pred)
          else:
              target = softness * tf.ones_like(pred)
          entropy = tf.nn.sigmoid_cross_entropy_with_logits(
              logits=pred, labels=target
          )
          return tf.reduce_mean(entropy)
  
      return cross_entropy_op
  
file_path: NiftyNet/niftynet/layer/loss_gan.py
imports: from __future__ import absolute_import, print_function
  import tensorflow
  from niftynet.engine.application_factory import LossGANFactory
  from niftynet.layer.base_layer import Layer
label_desc: Use image node_id 1 for calling a global function with example usage: cross_entropy_function(is_real, softness) and returns: cross_entropy_op, tf