code: def spatial_pool(self, x):
      batch, channel, height, width = x.shape
      if self.pooling_type == "att":
          # [N*headers, C', H , W] C = headers * C'
          x = x.reshape(
              [
                  batch * self.headers,
                  self.single_header_inplanes,
                  height,
                  width,
              ]
          )
          input_x = x
  
          # [N*headers, C', H * W] C = headers * C'
          # input_x = input_x.view(batch, channel, height * width)
          input_x = input_x.reshape(
              [
                  batch * self.headers,
                  self.single_header_inplanes,
                  height * width,
              ]
          )
  
          # [N*headers, 1, C', H * W]
          input_x = input_x.unsqueeze(1)
          # [N*headers, 1, H, W]
          context_mask = self.conv_mask(x)
          # [N*headers, 1, H * W]
          context_mask = context_mask.reshape(
              [batch * self.headers, 1, height * width]
          )
  
          # scale variance
          if self.att_scale and self.headers > 1:
              context_mask = context_mask / paddle.sqrt(
                  self.single_header_inplanes
              )
  
          # [N*headers, 1, H * W]
          context_mask = self.softmax(context_mask)
  
          # [N*headers, 1, H * W, 1]
          context_mask = context_mask.unsqueeze(-1)
          # [N*headers, 1, C', 1] = [N*headers, 1, C', H * W] * [N*headers, 1, H * W, 1]
          context = paddle.matmul(input_x, context_mask)
  
          # [N, headers * C', 1, 1]
          context = context.reshape(
              [batch, self.headers * self.single_header_inplanes, 1, 1]
          )
      else:
          # [N, C, 1, 1]
          context = self.avg_pool(x)
  
      return context
  
file_path: PaddleOCR/ppocr/modeling/backbones/table_master_resnet.py
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 2 for calling the MultiAspectGCAttention obj's underlying member method code with example usage: obj.spatial_pool(x) and returns: context