original_docstring: Generate an operator to evaluate matrix-Hessian-products for a function.
  
      The passed function should take as arguments and return symbolic array(s),
      and likewise the returned function will act on symbolic arrays.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `k + n`-dimensional 'matrix' array `m` with shape `func(x).shape + x.shape`
      then we have the following equivalence
  
          matrix_hessian_product(func)(x)(m) == (
              tensordot(m, jacobian(jacobian(func))(x), k + n))
  
      where `tensordot` follows its NumPy semantics, i.e. `tensordot(a, b, n)`
      sums the products of components of `a` and `b` over the last `n` axes
      (dimensions) of `a` and first `n` dimensions of `b`.
  
      Args:
          func (Callable[..., Array]): Function which takes one or more arrays as
              arguments and returns an array.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator return the
              matrix-Hessian-product function, Jacobian and value of `func` as a
              3-tuple (True) or just the matrix-Hessian-product function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Array]]]:
              Generated matrix-Hessian-product operator.
      
docstring: Generate an operator to evaluate matrix-Hessian-products for a function.
  The passed function should take as arguments and return symbolic array(s),
  and likewise the returned function will act on symbolic arrays.
  
  
  
  
  
  
docstring_tokens: Generate an operator to evaluate matrix - Hessian - products for a function . The passed function should take as arguments and return symbolic array ( s ) and likewise the returned function will act on symbolic arrays .
code: def matrix_hessian_product(func, wrt=0, return_aux=False):
      """Generate an operator to evaluate matrix-Hessian-products for a function.
  
      The passed function should take as arguments and return symbolic array(s),
      and likewise the returned function will act on symbolic arrays.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `k + n`-dimensional 'matrix' array `m` with shape `func(x).shape + x.shape`
      then we have the following equivalence
  
          matrix_hessian_product(func)(x)(m) == (
              tensordot(m, jacobian(jacobian(func))(x), k + n))
  
      where `tensordot` follows its NumPy semantics, i.e. `tensordot(a, b, n)`
      sums the products of components of `a` and `b` over the last `n` axes
      (dimensions) of `a` and first `n` dimensions of `b`.
  
      Args:
          func (Callable[..., Array]): Function which takes one or more arrays as
              arguments and returns an array.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator return the
              matrix-Hessian-product function, Jacobian and value of `func` as a
              3-tuple (True) or just the matrix-Hessian-product function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Array]]]:
              Generated matrix-Hessian-product operator.
      """
  
      @_wrap_derived(func, 'mhp', 'matrix-Hessian-product')
      def mhp_func(*args):
          jac, val = jacobian(func, wrt, return_aux=True)(*args)
          hess = sym.diff(jac, args[wrt])
          m = _named_array('m', jac.shape)
          mhp = _generalised_dot(hess, m, args[wrt].shape)
          m_mhp = FunctionExpression((m,), mhp)
          return (m_mhp, jac, val) if return_aux else m_mhp
  
      return mhp_func
code_tokens: def matrix_hessian_product ( func , wrt = 0 , return_aux = False ) : @ _wrap_derived ( func , 'mhp' , 'matrix-Hessian-product' ) def mhp_func ( * args ) : jac , val = jacobian ( func , wrt , return_aux = True ) ( * args ) hess = sym . diff ( jac , args [ wrt ] ) m = _named_array ( 'm' , jac . shape ) mhp = _generalised_dot ( hess , m , args [ wrt ] . shape ) m_mhp = FunctionExpression ( ( m , ) , mhp ) return ( m_mhp , jac , val ) if return_aux else m_mhp return mhp_func
short_docstring: Generate an operator to evaluate matrix-Hessian-products for a function.
short_docstring_tokens: Generate an operator to evaluate matrix - Hessian - products for a function .
comment: """Generate an operator to evaluate matrix-Hessian-products for a function.
  
      The passed function should take as arguments and return symbolic array(s),
      and likewise the returned function will act on symbolic arrays.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `k + n`-dimensional 'matrix' array `m` with shape `func(x).shape + x.shape`
      then we have the following equivalence
  
          matrix_hessian_product(func)(x)(m) == (
              tensordot(m, jacobian(jacobian(func))(x), k + n))
  
      where `tensordot` follows its NumPy semantics, i.e. `tensordot(a, b, n)`
      sums the products of components of `a` and `b` over the last `n` axes
      (dimensions) of `a` and first `n` dimensions of `b`.
  
      Args:
          func (Callable[..., Array]): Function which takes one or more arrays as
              arguments and returns an array.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator return the
              matrix-Hessian-product function, Jacobian and value of `func` as a
              3-tuple (True) or just the matrix-Hessian-product function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Array]]]:
              Generated matrix-Hessian-product operator.
      """