def hessian(cost, wrt, consider_constant=None,
            disconnected_inputs='raise'):
    from theano.tensor import arange
    # Check inputs have the right format
    assert isinstance(cost, Variable), \
        "tensor.hessian expects a Variable as `cost`"
    assert cost.ndim == 0, \
        "tensor.hessian expects a 0 dimensional variable as `cost`"

    using_list = isinstance(wrt, list)
    using_tuple = isinstance(wrt, tuple)

    if isinstance(wrt, (list, tuple)):
        wrt = list(wrt)
    else:
        wrt = [wrt]

    hessians = []
    for input in wrt:
        assert isinstance(input, Variable), \
            "tensor.hessian expects a (list of) Variable as `wrt`"
        assert input.ndim == 1, \
            "tensor.hessian expects a (list of) 1 dimensional variable "\
            "as `wrt`"
        expr = grad(cost, input, consider_constant=consider_constant,
                    disconnected_inputs=disconnected_inputs)

        # It is possible that the inputs are disconnected from expr,
        # even if they are connected to cost.
        # This should not be an error.
        hess, updates = theano.scan(lambda i, y, x: grad(
            y[i],
            x,
            consider_constant=consider_constant,
            disconnected_inputs='ignore'),
            sequences=arange(expr.shape[0]),
            non_sequences=[expr, input])
        assert not updates, \
            ("Scan has returned a list of updates. This should not "
             "happen! Report this to theano-users (also include the "
             "script that generated the error)")
        hessians.append(hess)
    return format_as(using_list, using_tuple, hessians)
:type cost: Scalar (0-dimensional) Variable.
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/gradient.py/hessian