class_docstr: Position attention module.
class_docstr_tok: ["Position","attention","module","."]
code: def forward(self, x: paddle.Tensor) -> paddle.Tensor:
      x_shape = paddle.shape(x)
  
      # query: n, h * w, c1
      query = self.query_conv(x)
      query = paddle.reshape(query, (0, self.mid_channels, -1))
      query = paddle.transpose(query, (0, 2, 1))
  
      # key: n, c1, h * w
      key = self.key_conv(x)
      key = paddle.reshape(key, (0, self.mid_channels, -1))
  
      # sim: n, h * w, h * w
      sim = paddle.bmm(query, key)
      sim = F.softmax(sim, axis=-1)
  
      value = self.value_conv(x)
      value = paddle.reshape(value, (0, self.in_channels, -1))
      sim = paddle.transpose(sim, (0, 2, 1))
  
      # feat: from (n, c2, h * w) -> (n, c2, h, w)
      feat = paddle.bmm(value, sim)
      feat = paddle.reshape(
          feat, (0, self.in_channels, x_shape[2], x_shape[3])
      )
  
      out = self.gamma * feat + x
      return out
  
imports: import os
  from typing import Union, List, Tuple
  import paddle
  from paddle import nn
  import paddle.nn.functional
  import numpy
  from paddlehub.module.module import moduleinfo
  import paddlehub.vision.segmentation_transforms
  from paddlehub.module.cv_module import ImageSegmentationModule
  from danet_resnet50_voc.resnet import ResNet50_vd
  import danet_resnet50_voc.layers
label_desc: Use image node_id 2 for calling the PAM obj's underlying member method code with example usage: obj.forward(x) and returns: out