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.
  Uses three q, k, v linear layers to compute attention
class_docstr_tok: ["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",".","Uses","three","q",",","k",",","v","linear","layers","to","compute","attention"]
code: def __init__(
      self,
      channels,
      num_head_channels=None,
      num_groups=32,
      rescale_output_factor=1.0,
      eps=1e-5,
  ):
      super().__init__()
      self.channels = channels
  
      self.num_heads = (
          channels // num_head_channels
          if num_head_channels is not None
          else 1
      )
      self.num_head_size = num_head_channels
      self.group_norm = nn.GroupNorm(
          num_channels=channels, num_groups=num_groups, epsilon=eps
      )
  
      # define q,k,v as linear layers
      self.query = nn.Linear(channels, channels)
      self.key = nn.Linear(channels, channels)
      self.value = nn.Linear(channels, channels)
  
      self.rescale_output_factor = rescale_output_factor
      self.proj_attn = nn.Linear(channels, channels)
  
imports: import math
  from inspect import isfunction
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 1 to create a new AttentionBlockNew object from inherited base classes: nn with example: obj = AttentionBlockNew(channels, num_head_channels, num_groups, rescale_output_factor, eps)