<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encoder_vgg(x, enc_final_size, reuse=False, scope_prefix='', hparams=None, is_training=True):
 """VGG network to use as encoder without the top few layers. Can be pretrained. Args: x: The image to encode. In the range 0 to 1. enc_final_size: The desired size of the encoding. reuse: To reuse in variable scope or not. scope_prefix: The prefix before the scope name. hparams: The python hparams. is_training: boolean value indicating if training is happening. Returns: The generated image. """

  with tf.variable_scope(scope_prefix + 'encoder', reuse=reuse):

    # Preprocess input
    x *= 256
    x = x - COLOR_NORMALIZATION_VECTOR

    with arg_scope(vgg.vgg_arg_scope()):
      # Padding because vgg_16 accepts images of size at least VGG_IMAGE_SIZE.
      x = tf.pad(x, [[0, 0], [0, VGG_IMAGE_SIZE - IMG_WIDTH],
                     [0, VGG_IMAGE_SIZE - IMG_HEIGHT], [0, 0]])
      _, end_points = vgg.vgg_16(
          x,
          num_classes=enc_final_size,
          is_training=is_training)
      pool5_key = [key for key in end_points.keys() if 'pool5' in key]
      assert len(pool5_key) == 1
      enc = end_points[pool5_key[0]]
      # Undoing padding.
      enc = tf.slice(enc, [0, 0, 0, 0], [-1, 2, 2, -1])

    enc_shape = enc.get_shape().as_list()
    enc_shape[0] = -1
    enc_size = enc_shape[1] * enc_shape[2] * enc_shape[3]

    enc_flat = tf.reshape(enc, (-1, enc_size))
    enc_flat = tf.nn.dropout(enc_flat, hparams.enc_keep_prob)

    enc_flat = tf.layers.dense(
        enc_flat,
        enc_final_size,
        kernel_initializer=tf.truncated_normal_initializer(stddev=1e-4,))

    if hparams.enc_pred_use_l2norm:
      enc_flat = tf.nn.l2_normalize(enc_flat, 1)

  return enc_flat