def forward(self, x):
    (B, N, C) = x.shape
    qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, (C // self.num_heads)).permute(2, 0, 3, 1, 4)
    (q, k, v) = (qkv[0], qkv[1], qkv[2])
    attn = ((q @ k.transpose((- 2), (- 1))) * self.scale)
    attn = attn.softmax(dim=(- 1))
    attn = self.attn_drop(attn)
    x = (attn @ v).transpose(1, 2).reshape(B, N, C)
    x = self.proj(x)
    x = self.proj_drop(x)
    return (x, attn)
def forward(self, x):
    (B, N, C) = x.shape
    qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, (C // self.num_heads)).permute(2, 0, 3, 1, 4)
    (q, k, v) = (qkv[0], qkv[1], qkv[2])
    attn = ((q @ k.transpose((- 2), (- 1))) * self.scale)
    attn = attn.softmax(dim=(- 1))
    attn = self.attn_drop(attn)
    x = (attn @ v).transpose(1, 2).reshape(B, N, C)
    x = self.proj(x)
    x = self.proj_drop(x)
    return (x, attn)