import tensorflow as tf

      x_blend_np = sess.run(x_blend)
      x_blend_expected_np = 0.8 * sess.run(
          layers.upscale(layers.downscale(x, 2), 2)) + 0.2 * x_np
    self.assertNDArrayNear(x_blend_np, x_blend_expected_np, 1.0e-6)

  def test_num_filters(self):
    self.assertEqual(networks.num_filters(1, 4096, 1, 256), 256)
    self.assertEqual(networks.num_filters(5, 4096, 1, 256), 128)

  def test_generator_grad_norm_progress(self):
    stable_stage_num_images = 2
    transition_stage_num_images = 3

    current_image_id_ph = tf.placeholder(tf.int32, [])
    progress = networks.compute_progress(
        current_image_id_ph,
        stable_stage_num_images,
        transition_stage_num_images,
        num_blocks=3)
    z = tf.random_normal([2, 10], dtype=tf.float32)
    x, _ = networks.generator(
        z, progress, _num_filters_stub,
        networks.ResolutionSchedule(
            start_resolutions=(4, 4), scale_base=2, num_resolutions=3))
    fake_loss = tf.reduce_sum(tf.square(x))
    grad_norms = [
