code: def forward(self, fmap):
      fmap = self.norm(fmap)
  
      shape, p = fmap.shape, self.patch_size
      b, n, x, y, h = *shape, self.heads
      x, y = map(lambda t: t // p, (x, y))
  
      fmap = rearrange(
          fmap, "b c (x p1) (y p2) -> (b x y) c p1 p2", p1=p, p2=p
      )
  
      q, k, v = (self.to_q(fmap), *self.to_kv(fmap).chunk(2, dim=1))
      q, k, v = map(
          lambda t: rearrange(
              t, "b (h d) p1 p2 -> (b h) (p1 p2) d", h=h
          ),
          (q, k, v),
      )
  
      dots = einsum("b i d, b j d -> b i j", q, k) * self.scale
  
      attn = dots.softmax(dim=-1)
  
      out = einsum("b i j, b j d -> b i d", attn, v)
      out = rearrange(
          out,
          "(b x y h) (p1 p2) d -> b (h d) (x p1) (y p2)",
          h=h,
          x=x,
          y=y,
          p1=p,
          p2=p,
      )
      return self.to_out(out)
  
imports: import torch
  from torch import nn, einsum
  import torch.nn.functional
  from einops import rearrange, repeat
  from einops.layers.torch import Rearrange
label_desc: Use image node_id 2 for calling the LocalAttention obj's underlying member method code with example usage: obj.forward(fmap) and returns: self