def user_function(info, x, obj, dobj, ddobj, g, dg, n2, n3, n4, imode, driver):
    """
       Calculate the objective functions, constraints,
         and gradients of those. Call back to the driver
         to get the values that were plugged
         in.

       Note, there is some evidence of loss of precision on the output of
       this function.
    """

    # evaluate objective function or constraint function
    if info in [1, 2]:

        if imode == 1:

            # We are in a finite difference step drive by NEWSUMT

            # Note, NEWSUMT estimates 2nd-order derivatives from
            # the first order differences.

            # Save baseline states and calculate derivatives
            #if driver.baseline_point:
            #    driver.calc_derivatives(first=True, savebase=True)
            #driver.baseline_point = False

            # update the parameters in the model
            driver.set_parameters(x)
            super(NEWSUMTdriver, driver).run_iteration()

        else:

            # Optimization step
            driver.set_parameters(x)
            super(NEWSUMTdriver, driver).run_iteration()

        # evaluate objectives
        if info == 1:
            obj = driver.eval_objective()

        # evaluate constraint functions
        if info == 2:
            for i, v in enumerate(driver.eval_ineq_constraints(driver.parent)):
                g[i] = -v

        # save constraint values in driver if this isn't a finite difference
        if imode != 1:
            driver.constraint_vals = g

    elif info == 3:
        # evaluate the first and second order derivatives
        #     of the objective function

        # NEWSUMT bug: sometimes we end up here when ifd=-4
        if driver.newsumt_diff:
            return obj, dobj, ddobj, g, dg

        msg = "Hessians currently not supported by OpenMDAO differentiator"
        raise NotImplementedError(msg)

        #driver.differentiator.calc_gradient()
        #driver.differentiator.calc_hessian(reuse_first=True)

        #obj_name = driver.get_objectives().keys()[0]
        #dobj = driver.differentiator.get_gradient(obj_name)

        #i_current = 0
        #names = driver.get_parameters().keys()
        #for row, name1 in enumerate(names):
            #for name2 in names[0:row+1]:
                #ddobj[i_current] = driver.differentiator.get_2nd_derivative(obj_name, wrt=(name1, name2))
                #i_current += 1

    elif [4, 5] in info:
        # evaluate gradient of nonlinear or linear constraints.

        # Linear gradients are only called once, at startup
        if info == 5:
            # NEWSUMT bug - During initial run, NEWSUMT will ask for analytic
            # derivatives of the linear constraints even when ifd=-4. The only
            # thing we can do is return zero.
            if driver.newsumt_diff:
                return obj, dobj, ddobj, g, dg

            raise RuntimeError("newsumt ifd value of %d is not handled" % info)
            #driver.differentiator.calc_gradient()

        #i_current = 0
        #for param_name in driver.get_parameters():
            #for con_name in driver.get_ineq_constraints():
                #dg[i_current] = -driver.differentiator.get_derivative(con_name, wrt=param_name)
                #i_current += 1

    return obj, dobj, ddobj, g, dg
# pylint: enable=W0613
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/drivers/newsumtdriver.py/user_function/swapped operands of `in`