opt_einsum is a neat library that can optimize eisum formulations on the fly, but can also be used to simplify formulas to find better structures.
The script eincheck.py
shows an example run on
X = np.random.randn(16, 9, 676)
Y = np.random.randn(16, 32, 676)
np.einsum('bkl,bml,bkn,bmn->mk', X, Y, X, Y)