code: def build_graph(self, image_pos):
      image_pos = image_pos / 128.0 - 1
  
      z = tf.random_normal([self.batch, self.zdim], name="z_train")
      z = tf.placeholder_with_default(z, [None, self.zdim], name="z")
  
      with argscope(
          [Conv2D, Conv2DTranspose, FullyConnected],
          kernel_initializer=tf.truncated_normal_initializer(
              stddev=0.02
          ),
      ):
          with tf.variable_scope("gen"):
              image_gen = self.generator(z)
          tf.summary.image(
              "generated-samples", image_gen, max_outputs=30
          )
  
          alpha = tf.random_uniform(
              shape=[self.batch, 1, 1, 1],
              minval=0.0,
              maxval=1.0,
              name="alpha",
          )
          interp = image_pos + alpha * (image_gen - image_pos)
  
          with tf.variable_scope("discrim"):
              vecpos = self.discriminator(image_pos)
              vecneg = self.discriminator(image_gen)
              vec_interp = self.discriminator(interp)
  
      # the Wasserstein-GAN losses
      self.d_loss = tf.reduce_mean(vecneg - vecpos, name="d_loss")
      self.g_loss = tf.negative(tf.reduce_mean(vecneg), name="g_loss")
  
      # the gradient penalty loss
      gradients = tf.gradients(vec_interp, [interp])[0]
      gradients = tf.sqrt(
          tf.reduce_sum(tf.square(gradients), [1, 2, 3])
      )
      gradients_rms = tf.sqrt(
          tf.reduce_mean(tf.square(gradients)), name="gradient_rms"
      )
      gradient_penalty = tf.reduce_mean(
          tf.square(gradients - 1), name="gradient_penalty"
      )
      add_moving_summary(
          self.d_loss, self.g_loss, gradient_penalty, gradients_rms
      )
  
      self.d_loss = tf.add(self.d_loss, 10 * gradient_penalty)
  
      self.collect_variables()
  
file_path: tensorpack/examples/GAN/Improved-WGAN.py
imports: import tensorflow
  from tensorpack import *
  from tensorpack.tfutils import get_tf_version_tuple
  from tensorpack.tfutils.scope_utils import auto_reuse_variable_scope
  from tensorpack.tfutils.summary import add_moving_summary
  import DCGAN
  from GAN import SeparateGANTrainer
label_desc: Use image node_id 2 for calling the Model obj's underlying member method code with example usage: obj.build_graph(image_pos) without return types