<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hessian(L, Y, U, adj = False, inv = False, factored_updates = False):
 """ Supernodal multifrontal Hessian mapping. The mapping .. math:: \mathcal H_X(U) = P(X^{-1}UX^{-1}) is the Hessian of the log-det barrier at a positive definite chordal matrix :math:`X`, applied to a symmetric chordal matrix :math:`U`. The Hessian operator can be factored as .. math:: \mathcal H_X(U) = \mathcal G_X^{\mathrm adj}( \mathcal G_X(U) ) where the mappings on the right-hand side are adjoint mappings that map chordal symmetric matrices to chordal symmetric matrices. This routine evaluates the mapping :math:`G_X` and its adjoint :math:`G_X^{\mathrm adj}` as well as the corresponding inverse mappings. The inputs `adj` and `inv` control the action as follows: | Action |`adj` | `inv` | +==================================================+========+=======+ | :math:`U = \mathcal G_X(U)` | False | False | | :math:`U = \mathcal G_X^{\mathrm adj}(U)` | True | False | | :math:`U = \mathcal G_X^{-1}(U)` | False | True | | :math:`U = \mathcal (G_X^{\mathrm adj})^{-1}(U)` | True | True | The input argument :math:`L` is the Cholesky factor of :math:`X`. The input argument :math:`Y` is the projected inverse of :math:`X`. The input argument :math:`U` is either a chordal matrix (a :py:class:`cspmatrix`) of a list of chordal matrices with the same sparsity pattern as :math:`L` and :math:`Y`. The optional argument `factored_updates` can be used to enable (if True) or disable (if False) updating of intermediate factorizations. :param L: :py:class:`cspmatrix` (factor) :param Y: :py:class:`cspmatrix` :param U: :py:class:`cspmatrix` or list of :py:class:`cspmatrix` objects :param adj: boolean :param inv: boolean :param factored_updates: boolean """

    assert L.symb == Y.symb, "Symbolic factorization mismatch"
    assert isinstance(L, cspmatrix) and L.is_factor is True, "L must be a cspmatrix factor"
    assert isinstance(Y, cspmatrix) and Y.is_factor is False, "Y must be a cspmatrix"

    if isinstance(U, cspmatrix):
        assert U.is_factor is False,\
            "U must be a cspmatrix or a list of cbsmatrices"
        U = [U]
    else:
        for Ut in U:
            assert Ut.symb == L.symb, "Symbolic factorization mismatch"
            assert isinstance(Ut, cspmatrix) and Ut.is_factor is False,\
                "U must be a cspmatrix or a list of cbsmatrices"

    if adj is False and inv is False:
        __Y2K(L, U, inv = inv)
        __scale(L, Y, U, inv = inv, adj = adj, factored_updates = factored_updates)

    elif adj is True and inv is False:
        __scale(L, Y, U, inv = inv, adj = adj, factored_updates = factored_updates)
        __M2T(L, U, inv = inv)

    elif adj is True and inv is True:
        __M2T(L, U, inv = inv)
        __scale(L, Y, U, inv = inv, adj = adj, factored_updates = factored_updates)

    elif adj is False and inv is True:
        __scale(L, Y, U, inv = inv, adj = adj, factored_updates = factored_updates)
        __Y2K(L, U, inv = inv)

    elif adj is None and inv is False:
        __Y2K(L, U, inv = inv)
        __scale(L, Y, U, inv = inv, adj = False, factored_updates = factored_updates)
        __scale(L, Y, U, inv = inv, adj = True,  factored_updates = factored_updates)
        __M2T(L, U, inv = inv)

    elif adj is None and inv is True:
        __M2T(L, U, inv = inv)
        __scale(L, Y, U, inv = inv, adj = True,  factored_updates = factored_updates)
        __scale(L, Y, U, inv = inv, adj = False, factored_updates = factored_updates)
        __Y2K(L, U, inv = inv)

    return