class_docstr: An attention block that allows spatial positions to attend to each other.
  
  Originally ported from here, but adapted to the N-d case.
  https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/models/unet.py#L66.
code: def forward(self, x, encoder_out=None):
      b, c, *spatial = x.shape
      qkv = self.qkv(self.norm(x).view(b, c, -1))
      if encoder_out is not None:
          encoder_out = self.encoder_kv(encoder_out)
          h = self.attention(qkv, encoder_out)
      else:
          h = self.attention(qkv)
      h = self.proj_out(h)
      return x + h.reshape(b, c, *spatial)
  
imports: import math
  from abc import abstractmethod
  import torch
  import torch.nn
  import torch.nn.functional
  from .fp16_util import convert_module_to_f16, convert_module_to_f32
  from .nn import avg_pool_nd, conv_nd, linear, normalization, timestep_embedding, zero_module
label_desc: Use image node_id 2 for calling the AttentionBlock obj's underlying member method code with example usage: obj.forward(x, encoder_out) and returns: unknown