class_docstr: Basic Non-local module.
  This model is the implementation of "Non-local Neural Networks"
  (https://arxiv.org/abs/1711.07971)
  
  Args:
      in_channels (int): Channels of the input feature map.
      reduction (int): Channel reduction ratio. Default: 2.
      use_scale (bool): Whether to scale pairwise_weight by `1/sqrt(inter_channels)` when the mode is `embedded_gaussian`. Default: True.
      sub_sample (bool): Whether to utilize max pooling after pairwise function. Default: False.
      mode (str): Options are `gaussian`, `concatenation`, `embedded_gaussian` and `dot_product`. Default: embedded_gaussian.
code: def embedded_gaussian(self, theta_x, phi_x):
      pairwise_weight = paddle.matmul(theta_x, phi_x)
      if self.use_scale:
          pairwise_weight /= theta_x.shape[-1] ** 0.5
      pairwise_weight = F.softmax(pairwise_weight, -1)
      return pairwise_weight
  
file_path: PaddleSeg/paddleseg/models/layers/nonlocal2d.py
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.models import layers
label_desc: Use image node_id 3 for calling the NonLocal2D obj's underlying member method code with example usage: obj.embedded_gaussian(theta_x, phi_x) and returns: pairwise_weight