Answering my own question, einsum seems to fit perfectly with the problem (I can even use the same schematic notation I used in the question lol). If there is some way that is more specific then someone might feel free to comment.