code: def encode(x, x_space, hparams, name):
    
    with tf.variable_scope(name):
      (encoder_input, encoder_self_attention_bias,
       ed) = transformer.transformer_prepare_encoder(x, x_space, hparams)
      encoder_input = tf.nn.dropout(encoder_input, 1.0 - hparams.dropout)
      return transformer.transformer_encoder(
          encoder_input, encoder_self_attention_bias, hparams), ed
docs: Transformer preparations and encoder.