human
I wrote the below code

    desired_div = (FLAGS.max_divergence * np.mean(lengths))
    def calc_divergence(eps_lambda):
        max_reward = np.max(rewards)
        logz = ((max_reward / eps_lambda) + np.log(np.mean(np.exp(((rewards - max_reward) / eps_lambda)))))
        exprr = np.mean(((np.exp(((rewards / eps_lambda) - logz)) * rewards) / eps_lambda))
        return (exprr - logz)
    left = 0.0
    right = 1000.0
    if (len(rewards) <= 8):
        return ((left + right) / 2)
    num_iter = max(4, (1 + int((np.log(((right - left) / 0.1)) / np.log(2.0)))))
    for _ in xrange(num_iter):
        mid = ((left + right) / 2)
        cur_div = calc_divergence(mid)
        if (cur_div > desired_div):
            left = mid
        else:
            right = mid
    return ((left + right) / 2)

What's a good function header?
 ... Here's a good function header?
assistant
#Here's a good function header.

def find_best_eps_lambda(rewards, lengths):