code: def get_encoder_component(name,
                            input_layer,
                            head_num,
                            hidden_dim,
                            attention_activation=None,
                            feed_forward_activation='relu',
                            dropout_rate=0.0,
                            trainable=True):
      
      attention_name = '%s-MultiHeadSelfAttention' % name
      feed_forward_name = '%s-FeedForward' % name
      attention_layer = _wrap_layer(
          name=attention_name,
          input_layer=input_layer,
          build_func=attention_builder(
              name=attention_name,
              head_num=head_num,
              activation=attention_activation,
              history_only=False,
              trainable=trainable,
          ),
          dropout_rate=dropout_rate,
          trainable=trainable,
      )
      feed_forward_layer = _wrap_layer(
          name=feed_forward_name,
          input_layer=attention_layer,
          build_func=feed_forward_builder(
              name=feed_forward_name,
              hidden_dim=hidden_dim,
              activation=feed_forward_activation,
              trainable=trainable,
          ),
          dropout_rate=dropout_rate,
          trainable=trainable,
      )
      return feed_forward_layer
docs: Multi-head self-attention and feed-forward layer.
  
      :param name: Prefix of names for internal layers.
      :param input_layer: Input layer.
      :param head_num: Number of heads in multi-head self-attention.
      :param hidden_dim: Hidden dimension of feed forward layer.
      :param attention_activation: Activation for multi-head self-attention.
      :param feed_forward_activation: Activation for feed-forward layer.
      :param dropout_rate: Dropout rate.
      :param trainable: Whether the layers are trainable.
      :return: Output layer.