Self attention in pixelcnn


Hi all,
I want to add the causal self attention block in my network (PixelCNN), but i can’t find any good material to start from. Recently I came across the picture shown, which have self attention mechanism. But I don’t know how to code it. If you help me, it is greatly appreciated. Please let me know where to start from and where to look like reference or some literature etc. Thanks in advance.

Cheers