code: def encoder_layer(
      enc_input,
      input_mask,
      attn_bias,
      n_head,
      d_key,
      d_value,
      d_model,
      d_inner_hid,
      prepostprocess_dropout,
      attention_dropout,
      relu_dropout,
      hidden_act,
      preprocess_cmd="n",
      postprocess_cmd="da",
      param_initializer=None,
      name="",
  ):
      """The encoder layers that can be stacked to form a deep encoder.
      This module consits of a multi-head (self) attention followed by
      position-wise feed-forward networks and both the two components companied
      with the post_process_layer to add residual connection, layer normalization
      and droput.
      """
      attn_output, ctx_multiheads_attn = multi_head_attention(
          pre_process_layer(
              enc_input,
              preprocess_cmd,
              prepostprocess_dropout,
              name=name + "_pre_att",
          ),
          None,
          None,
          attn_bias,
          d_key,
          d_value,
          d_model,
          input_mask,
          n_head,
          attention_dropout,
          param_initializer=param_initializer,
          name=name + "_multi_head_att",
      )
      attn_output = post_process_layer(
          enc_input,
          attn_output,
          postprocess_cmd,
          prepostprocess_dropout,
          name=name + "_post_att",
      )
  
      ffd_output = positionwise_feed_forward(
          pre_process_layer(
              attn_output,
              preprocess_cmd,
              prepostprocess_dropout,
              name=name + "_pre_ffn",
          ),
          d_inner_hid,
          d_model,
          relu_dropout,
          hidden_act,
          param_initializer=param_initializer,
          name=name + "_ffn",
      )
  
      ret = post_process_layer(
          attn_output,
          ffd_output,
          postprocess_cmd,
          prepostprocess_dropout,
          name=name + "_post_ffn",
      )
  
      return ret, ctx_multiheads_attn, ffd_output
  
file_path: PGL/legacy/examples/xformer/transformer_encoder_sparse.py
imports: from functools import partial
  import paddle.fluid
  import paddle.fluid.layers
  import paddle.fluid.layers
  from .sparse_scaled_dot_product_attention import sparse_scaled_dot_product_attention
label_desc: Use image node_id 4 for calling a global function with example usage: encoder_layer(enc_input, input_mask, attn_bias, n_head, d_key, d_value, d_model, d_inner_hid, prepostprocess_dropout, attention_dropout, relu_dropout, hidden_act, preprocess_cmd, postprocess_cmd, param_initializer, name) and returns: ret,  ctx_multiheads_attn,  ffd_output