Numpy: Multiplying a matrix with a 3d tensor -- Suggestion,"scipy.tensordot(P, T, axes=[1, 1]).swapaxes(0, 1)"