//  [python]
def _build_graph(self, inputs):

        # keep track of statistics to interpolate between different checkpoints
        # from 0 (only old checkpoint) to 1 (only new network)
        glbstep = tf.identity(get_global_step_var(), name="glob_step")
        seen_images = tf.cast(get_global_step_var() * BATCH_SIZE, tf.int64, name='seen_images')
        if TRANSITION:
            alpha = tf.divide(tf.cast(seen_images, tf.float32), tf.cast(NUM_IMAGES, tf.float32), name='alpha')
            transition_phase = tf.get_variable('transistion_phase', initializer=1., trainable=False, dtype=tf.float32)
        else:
            alpha = tf.identity(0, name='alpha')
            transition_phase = tf.get_variable('transistion_phase', initializer=0., trainable=False, dtype=tf.float32)
        add_moving_summary(alpha, seen_images, tf.identity(transition_phase, name="transistion"), glbstep)

        if TRANSITION:
            real_img, real_prev = inputs[0] / 128.0 - 1, Upsample("upsample_realprev", inputs[1] / 128.0 - 1, factor=2)
            real_img = combine_img(real_img, real_prev, alpha)
        else:
            real_prev = None
            real_img, real_prev = inputs[0] / 128.0 - 1, None

        # noise which the generator is starting from
        z = tf.random_uniform([BATCH_SIZE, NOISE_DIM], -1, 1, name='z_train')
        z = tf.placeholder_with_default(z, [None, NOISE_DIM], name='z')

        # GENERATOR
        # ---------------------------------------------------------------------
        with tf.variable_scope('gen'):
            fake_img = self.generator(z, alpha=alpha)
            visualize_images('real_fake', real_img, fake_img)

            fake_output = (fake_img + 1.) * 128.
            fake_output = tf.cast(tf.clip_by_value(fake_output, 0, 255), tf.uint8, name='viz')
            tf.identity(fake_output, name='fake_img')

        # DISCRIMINATOR
        # ---------------------------------------------------------------------
        with tf.variable_scope('discrim'):
            WGAN_alpha = tf.random_uniform(shape=[BATCH_SIZE, 1, 1, 1], minval=0., maxval=1., name='alpha')
            interp_img = real_img + WGAN_alpha * (fake_img - real_img)

            visualize_images('real_fake_interp', real_img, fake_img, interp_img)

            real_score = self.discriminator(real_img, alpha=alpha)
            fake_score = self.discriminator(fake_img, alpha=alpha)
            interp_score = self.discriminator(interp_img, alpha=alpha)

            mean_real_score = tf.reduce_mean(real_score, name='mean_real_score')
            mean_fake_score = tf.reduce_mean(fake_score, name='mean_fake_score')
            mean_interp_score = tf.reduce_mean(interp_score, name='mean_interp_score')
            add_moving_summary(mean_real_score, mean_fake_score, mean_interp_score)

        # the Wasserstein-GAN losses
        self.d_loss = tf.reduce_mean(fake_score - real_score, name='d_loss')
        self.g_loss = tf.negative(tf.reduce_mean(fake_score), name='g_loss')
        loss_diff = tf.subtract(self.g_loss, self.d_loss, name="loss-diff-g-d")
        add_moving_summary(self.d_loss, self.g_loss, loss_diff)

        # the gradient penalty loss
        def wasserstein_grad_penalty(score, input, name=None):
            with tf.name_scope(name):
                gradients = tf.gradients(score, [input])[0]
                gradients = tf.sqrt(tf.reduce_sum(tf.square(gradients), [1, 2, 3]))
                gradients_rms = symbolic_functions.rms(gradients, 'gradient_rms')
                gradient_penalty = tf.reduce_mean(tf.square(gradients - 1), name='gradient_penalty')
                return gradients_rms, gradient_penalty

        gradients_rms, gradient_penalty = wasserstein_grad_penalty(interp_score, interp_img)
        add_moving_summary(gradient_penalty, gradients_rms)

        # drift-loss
        drift_loss = tf.reduce_mean(tf.square(real_score), name='drift_loss')
        self.d_loss = tf.add_n([self.d_loss, 10 * gradient_penalty, EPS_DRIFT * drift_loss], name='total_d_loss')
        add_moving_summary(self.d_loss, drift_loss)

        self.collect_variables()

        def count_params_in_scope(scope):
            vs = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope)
            return np.sum([int(np.prod(v.shape)) for v in vs])

        logger.info(colored("Number of Parameters:", 'cyan'))
        logger.info("generator #params:     {:,}".format(count_params_in_scope('gen')))
        logger.info("discriminator #params: {:,}".format(count_params_in_scope('discrim')))