Converting an expression into an einsum I have the following expression that I need to calculate for some matrices: