<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Small scale example
Step1:  Example with more savings, but slower to optimize
Step2:  Look at the recommendations
<ASSISTANT_TASK:>
Python Code:
def func(a, b, c):
    res = tf.einsum('ijk,ja,kb->iab', a, b, c) + 1
    res = tf.einsum('iab,kb->iak', res, c)
    return res
a = tf.random_normal((10, 11, 12))
b = tf.random_normal((11, 13))
c = tf.random_normal((12, 14))
# res = func(a, b, c)
orders, optimized_func = tf_einsum_opt.optimizer(func, sess, a, b, c)
res1 = func(a, b, c)
%timeit sess.run(res1)
res2 = optimized_func(a, b, c)
%timeit sess.run(res2)
# Check that the results of optimized and the original function are the same.
np.testing.assert_allclose(*sess.run([res1, res2]), rtol=1e-5, atol=1e-5)
Explanation: Small scale example
End of explanation
def func(a, b, c, d):
    res = tf.einsum('si,sj,sk,ij->s', a, b, d, c)
    res += tf.einsum('s,si->s', res, a)
    return res
a = tf.random_normal((100, 101))
b = tf.random_normal((100, 102))
c = tf.random_normal((101, 102))
d = tf.random_normal((100, 30))
orders, optimized_func = tf_einsum_opt.optimizer(func, sess, a, b, c, d)
res1 = func(a, b, c, d)
%timeit sess.run(res1)
res2 = optimized_func(a, b, c, d)
%timeit sess.run(res2)
Explanation: Example with more savings, but slower to optimize
End of explanation
orders
Explanation: Look at the recommendations:
End of explanation
<END_TASK>