Consider the following pytorch snippet:
X = torch.einsum("rij, sij -> rs", A, A)
Y = torch.einsum("rij, sij -> rs", B, B)
Z = torch.einsum("rij, sij -> rs", C, C)
torch.einsum("ij, ij, ij -> ", X, Y, Z)
which performs the following summation
Is it possible to formulate this in a more succinct (that is more vectorised/optimal) way? (e.g. using the fact that X, Y, Z are symmetric matrices)