class_docstr: The ExternalAttention implementation based on PaddlePaddle.
  Args:
      in_channels (int, optional): The input channels.
      inter_channels (int, optional): The channels of intermediate feature.
      out_channels (int, optional): The output channels.
      num_heads (int, optional): The num of heads in attention. Default: 8
      use_cross_kv (bool, optional): Wheter use cross_kv. Default: False
class_docstr_tok: ["The","ExternalAttention","implementation","based","on","PaddlePaddle",".","Args",":","in_channels","(","int",",","optional",")",":","The","input","channels",".","inter_channels","(","int",",","optional",")",":","The","channels","of","intermediate","feature",".","out_channels","(","int",",","optional",")",":","The","output","channels",".","num_heads","(","int",",","optional",")",":","The","num","of","heads","in","attention",".","Default",":","8","use_cross_kv","(","bool",",","optional",")",":","Wheter","use","cross_kv",".","Default",":","False"]
code: def _act_dn(self, x):
      x_shape = paddle.shape(x)
      h, w = x_shape[2], x_shape[3]
      x = x.reshape(
          [0, self.num_heads, self.inter_channels // self.num_heads, -1]
      )
      x = F.softmax(x, axis=3)
      x = x / (paddle.sum(x, axis=2, keepdim=True) + 1e-06)
      x = x.reshape([0, self.inter_channels, h, w])
      return x
  
imports: from functools import partial
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.cvlibs import manager, param_init
  from paddleseg.models import layers
  from paddleseg.utils import utils
  from paddleseg.models.backbones.transformer_utils import DropPath, Identity
  from paddleseg.cvlibs.param_init import constant_init, kaiming_normal_init, trunc_normal_init
label_desc: Use image node_id 4 for calling the ExternalAttention obj's underlying member method code with example usage: obj._act_dn(x) and returns: x