def dot_not_flat(A, B): """Equivalent of flattening matrices A, B and doing a vector product.""" return sum([th.sum(a * b) for a, b in zip(A, B)])