class_docstr: Uses xformers efficient implementation,
  see https://github.com/MatthieuTPHR/diffusers/blob/d80b531ff8060ec1ea982b65a1b8df70f73aa67c/src/diffusers/models/attention.py#L223
  Note: this is a single-head self-attention operation
class_docstr_tok: ["Uses","xformers","efficient","implementation",",","see","https",":","\/\/github.com\/MatthieuTPHR\/diffusers\/blob\/d80b531ff8060ec1ea982b65a1b8df70f73aa67c\/src\/diffusers\/models\/attention.py","#","L223","Note",":","this","is","a","single-head","self-attention","operation"]
code: def attention(self, h_: torch.Tensor) -> torch.Tensor:
      h_ = self.norm(h_)
      q = self.q(h_)
      k = self.k(h_)
      v = self.v(h_)
  
      # compute attention
      B, C, H, W = q.shape
      q, k, v = map(
          lambda x: rearrange(x, "b c h w -> b (h w) c"), (q, k, v)
      )
  
      q, k, v = map(
          lambda t: t.unsqueeze(3)
          .reshape(B, t.shape[1], 1, C)
          .permute(0, 2, 1, 3)
          .reshape(B * 1, t.shape[1], C)
          .contiguous(),
          (q, k, v),
      )
      out = xformers.ops.memory_efficient_attention(
          q, k, v, attn_bias=None, op=self.attention_op
      )
  
      out = (
          out.unsqueeze(0)
          .reshape(B, 1, out.shape[1], C)
          .permute(0, 2, 1, 3)
          .reshape(B, out.shape[1], C)
      )
      return rearrange(out, "b (h w) c -> b c h w", b=B, h=H, w=W, c=C)
  
imports: import logging
  import math
  from typing import Any, Callable, Optional
  import numpy
  import torch
  import torch.nn
  from einops import rearrange
  from packaging import version
  from ...modules.attention import LinearAttention, MemoryEfficientCrossAttention
label_desc: Use image node_id 2 for calling the MemoryEfficientAttnBlock obj's underlying member method code with example usage: obj.attention(h_) and returns: rearrange