human
I wrote the below code

    alpha0 = one
    phi_a0 = phi(alpha0)
    alpha1 = ((((- derphi0) * (alpha0 ** 2)) / 2.0) / ((phi_a0 - phi0) - (derphi0 * alpha0)))
    phi_a1 = phi(alpha1)
    csol1 = (phi_a0 <= (phi0 + (c1 * derphi0)))
    csol2 = (phi_a1 <= (phi0 + ((c1 * alpha1) * derphi0)))
    def armijo(alpha0, alpha1, phi_a0, phi_a1):
        factor = (((alpha0 ** 2) * (alpha1 ** 2)) * (alpha1 - alpha0))
        a = (((alpha0 ** 2) * ((phi_a1 - phi0) - (derphi0 * alpha1))) - ((alpha1 ** 2) * ((phi_a0 - phi0) - (derphi0 * alpha0))))
        a = (a / factor)
        b = (((- (alpha0 ** 3)) * ((phi_a1 - phi0) - (derphi0 * alpha1))) + ((alpha1 ** 3) * ((phi_a0 - phi0) - (derphi0 * alpha0))))
        b = (b / factor)
        alpha2 = (((- b) + TT.sqrt(abs(((b ** 2) - ((3 * a) * derphi0))))) / (3.0 * a))
        phi_a2 = phi(alpha2)
        end_condition = (phi_a2 <= (phi0 + ((c1 * alpha2) * derphi0)))
        end_condition = TT.bitwise_or(TT.isnan(alpha2), end_condition)
        end_condition = TT.bitwise_or(TT.isinf(alpha2), end_condition)
        alpha2 = TT.switch(TT.bitwise_or(((alpha1 - alpha2) > (alpha1 / constant(2.0))), ((one - (alpha2 / alpha1)) < 0.96)), (alpha1 / constant(2.0)), alpha2)
        return ([alpha1, alpha2, phi_a1, phi_a2], theano.scan_module.until(end_condition))
    states = [alpha0, alpha1, phi_a0, phi_a1]
    (rvals, _) = scan(armijo, outputs_info=states, n_steps=n_iters, name='armijo', mode=theano.Mode(linker='cvm'), profile=profile)
    sol_scan = rvals[1][(-1)]
    a_opt = ifelse(csol1, one, ifelse(csol2, alpha1, sol_scan))
    score = ifelse(csol1, phi_a0, ifelse(csol2, phi_a1, rvals[2][(-1)]))
    return (a_opt, score)

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

def scalar_armijo_search(phi, phi0, derphi0, c1=constant(0.0001), n_iters=10, profile=0):