code: def prepare_encoder(inputs, hparams, attention_type="local_1d"):
    
    x = prepare_image(inputs, hparams, name="enc_channels")
    # Add position signals.
    x = add_pos_signals(x, hparams, "enc_pos")
    x_shape = common_layers.shape_list(x)
    if attention_type == "local_1d":
      x = tf.reshape(x, [x_shape[0], x_shape[1]*x_shape[2], hparams.hidden_size])
      x.set_shape([None, None, hparams.hidden_size])
    elif attention_type == "local_2d":
      x.set_shape([None, None, None, hparams.hidden_size])
    return x
docs: Prepare encoder for images.