code: def wasserstein_loss(
      model,
      discriminator,
      discriminator_fake_logits,
      discriminator_real_logits,
      synthetic_images,
      reference_images,
      gradient_penalty_weight=10,
      name="discriminator",
      dim=2,
      depth=None,
      transition=False,
      alpha_transition=0,
  ):
      import tensorflow as tf
  
      if depth is None:
          depth = model.depth
  
      D_loss = tf.reduce_mean(
          discriminator_fake_logits
      ) - tf.reduce_mean(discriminator_real_logits)
      G_loss = -tf.reduce_mean(discriminator_fake_logits)
  
      differences = synthetic_images - reference_images
      alpha = tf.random_uniform(
          shape=[tf.shape(differences)[0]] + [1] * (dim + 1),
          minval=0.0,
          maxval=1.0,
      )
      interpolates = reference_images + (alpha * differences)
      _, interpolates_logits = discriminator(
          model,
          interpolates,
          reuse=True,
          depth=depth,
          name=name,
          transition=transition,
          alpha_transition=alpha_transition,
      )
      gradients = tf.gradients(interpolates_logits, [interpolates])[0]
  
      slopes = tf.sqrt(
          tf.reduce_sum(
              tf.square(gradients),
              reduction_indices=list(range(1, 2 + model.dim)),
          )
      )
      gradient_penalty = tf.reduce_mean((slopes - 1.0) ** 2)
      tf.summary.scalar("gp_loss", gradient_penalty)
  
      D_origin_loss = D_loss
      D_loss += 10 * gradient_penalty
      D_loss += 0.001 * tf.reduce_mean(
          tf.square(discriminator_real_logits - 0.0)
      )
  
      return [D_loss], [G_loss], [D_origin_loss]
  
imports: import numpy
  import itertools
label_desc: Use image node_id 6 for calling a global function with example usage: wasserstein_loss(model, discriminator, discriminator_fake_logits, discriminator_real_logits, synthetic_images, reference_images, gradient_penalty_weight, name, dim, depth, transition, alpha_transition) and returns: list,  list,  list