def forward(self, x):
    qkv = self.qkv(x)
    (q, k, v) = torch.chunk(qkv, 3, dim=(- 1))
    energy = (torch.bmm(q, k.transpose(1, 2)) / (self.d_attn ** 0.5))
    attn = self.softmax(energy)
    out = torch.bmm(attn, v)
    out = self.out(out)
    return out
def forward(self, x):
    qkv = self.qkv(x)
    (q, k, v) = torch.chunk(qkv, 3, dim=(- 1))
    energy = (torch.bmm(q, k.transpose(1, 2)) / (self.d_attn ** 0.5))
    attn = self.softmax(energy)
    out = torch.bmm(attn, v)
    out = self.out(out)
    return out