code: def positionwise_feed_forward(
      x,
      d_inner_hid,
      d_hid,
      dropout_rate,
      hidden_act,
      param_initializer=None,
      name="ffn",
  ):
      """
      Position-wise Feed-Forward Networks.
      This module consists of two linear transformations with a ReLU activation
      in between, which is applied to each position separately and identically.
      """
      hidden = layers.fc(
          input=x,
          size=d_inner_hid,
          num_flatten_dims=len(x.shape) - 1,
          act=hidden_act,
          param_attr=fluid.ParamAttr(
              name=name + "_fc_0.w_0", initializer=param_initializer
          ),
          bias_attr=name + "_fc_0.b_0",
      )
      if dropout_rate:
          hidden = layers.dropout(
              hidden,
              dropout_prob=dropout_rate,
              dropout_implementation="upscale_in_train",
              is_test=False,
          )
      out = layers.fc(
          input=hidden,
          size=d_hid,
          num_flatten_dims=len(hidden.shape) - 1,
          param_attr=fluid.ParamAttr(
              name=name + "_fc_1.w_0", initializer=param_initializer
          ),
          bias_attr=name + "_fc_1.b_0",
      )
      return out
  
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 2 for calling a global function with example usage: positionwise_feed_forward(x, d_inner_hid, d_hid, dropout_rate, hidden_act, param_initializer, name) and returns: out