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 transpose_for_scores(
      self, projection: paddle.Tensor
  ) -> paddle.Tensor:
      new_projection_shape = projection.shape[:-1] + [
          self.num_heads,
          -1,
      ]
      # move heads to 2nd position (B, T, H * D) -> (B, T, H, D) -> (B, H, T, D)
      new_projection = projection.reshape(
          new_projection_shape
      ).transpose([0, 2, 1, 3])
      return new_projection
  
imports: import math
  from inspect import isfunction
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 2 for calling the AttentionBlockNew obj's underlying member method code with example usage: obj.transpose_for_scores(projection) and returns: new_projection