class_docstr: Disentangled Non-Local Blocks.
  
  Args:
      temperature (float): Temperature to adjust attention.
class_docstr_tok: ["Disentangled","Non-Local","Blocks",".","Args",":","temperature","(","float",")",":","Temperature","to","adjust","attention","."]
code: def forward(self, x):
      x_shape = paddle.shape(x)
      g_x = (
          self.g(x)
          .reshape([0, self.inter_channels, -1])
          .transpose([0, 2, 1])
      )
  
      if self.mode == "gaussian":
          theta_x = paddle.transpose(
              x.reshape([0, self.in_channels, -1]), [0, 2, 1]
          )
          if self.sub_sample:
              phi_x = paddle.transpose(
                  self.phi(x), [0, self.in_channels, -1]
              )
          else:
              phi_x = paddle.transpose(x, [0, self.in_channels, -1])
  
      elif self.mode == "concatenation":
          theta_x = paddle.reshape(
              self.theta(x), [0, self.inter_channels, -1, 1]
          )
          phi_x = paddle.reshape(
              self.phi(x), [0, self.inter_channels, 1, -1]
          )
  
      else:
          theta_x = (
              self.theta(x)
              .reshape([0, self.inter_channels, -1])
              .transpose([0, 2, 1])
          )
          phi_x = paddle.reshape(
              self.phi(x), [0, self.inter_channels, -1]
          )
  
      theta_x -= paddle.mean(theta_x, axis=-2, keepdim=True)
      phi_x -= paddle.mean(phi_x, axis=-1, keepdim=True)
  
      pairwise_func = getattr(self, self.mode)
      pairwise_weight = pairwise_func(theta_x, phi_x)
  
      y = (
          paddle.matmul(pairwise_weight, g_x)
          .transpose([0, 2, 1])
          .reshape([0, self.inter_channels, x_shape[2], x_shape[3]])
      )
      unary_mask = F.softmax(
          paddle.reshape(self.conv_mask(x), [0, 1, -1]), -1
      )
      unary_x = (
          paddle.matmul(unary_mask, g_x)
          .transpose([0, 2, 1])
          .reshape([0, self.inter_channels, 1, 1])
      )
      output = x + self.conv_out(y + unary_x)
      return output
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.models import layers
  from paddleseg.cvlibs import manager
  from paddleseg.utils import utils
label_desc: Use image node_id 3 for calling the DisentangledNonLocal2D obj's underlying member method code with example usage: obj.forward(x) and returns: output