original_docstring: Generate an operator to evaluate Hessian-vector-products for a function.
  
      The passed function should take as arguments symbolic arrays and return a
      symbolic scalar, and likewise the returned operator will take symbolic array
      arguments.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `n`-dimensional 'vector' array `v` of the same shape as `x` then we have
      the following equivalence
  
          hessian_vector_product(func)(x)(v) == tensordot(hessian(func)(x), v, 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[..., Scalar]): Function which takes one or more arrays as
              arguments and returns a scalar.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator returns the
              Hessian-vector-product function, gradient and value of `func` as a
              3-tuple (True) or just the Hessian-vector-product function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Scalar]]]:
              Generated Hessian-vector-product operator.
      
docstring: Generate an operator to evaluate Hessian-vector-products for a function.
  The passed function should take as arguments symbolic arrays and return a
  symbolic scalar, and likewise the returned operator will take symbolic array
  arguments.
  
  
  
  
  
  
docstring_tokens: Generate an operator to evaluate Hessian - vector - products for a function . The passed function should take as arguments symbolic arrays and return a symbolic scalar and likewise the returned operator will take symbolic array arguments .
code: def hessian_vector_product(func, wrt=0, return_aux=False):
      """Generate an operator to evaluate Hessian-vector-products for a function.
  
      The passed function should take as arguments symbolic arrays and return a
      symbolic scalar, and likewise the returned operator will take symbolic array
      arguments.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `n`-dimensional 'vector' array `v` of the same shape as `x` then we have
      the following equivalence
  
          hessian_vector_product(func)(x)(v) == tensordot(hessian(func)(x), v, 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[..., Scalar]): Function which takes one or more arrays as
              arguments and returns a scalar.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator returns the
              Hessian-vector-product function, gradient and value of `func` as a
              3-tuple (True) or just the Hessian-vector-product function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Scalar]]]:
              Generated Hessian-vector-product operator.
      """
  
      @_wrap_derived(func, 'hvp', 'Hessian-vector-product')
      def hvp_func(*args):
          hess, grad, val = hessian(func, wrt, return_aux=True)(*args)
          v = _named_array('v', args[wrt].shape)
          hvp = _generalised_dot(hess, v, args[wrt].shape)
          v_hvp = FunctionExpression((v,), hvp)
          return (v_hvp, grad, val) if return_aux else v_hvp
  
      return hvp_func
code_tokens: def hessian_vector_product ( func , wrt = 0 , return_aux = False ) : @ _wrap_derived ( func , 'hvp' , 'Hessian-vector-product' ) def hvp_func ( * args ) : hess , grad , val = hessian ( func , wrt , return_aux = True ) ( * args ) v = _named_array ( 'v' , args [ wrt ] . shape ) hvp = _generalised_dot ( hess , v , args [ wrt ] . shape ) v_hvp = FunctionExpression ( ( v , ) , hvp ) return ( v_hvp , grad , val ) if return_aux else v_hvp return hvp_func
short_docstring: Generate an operator to evaluate Hessian-vector-products for a function.
short_docstring_tokens: Generate an operator to evaluate Hessian - vector - products for a function .
comment: """Generate an operator to evaluate Hessian-vector-products for a function.
  
      The passed function should take as arguments symbolic arrays and return a
      symbolic scalar, and likewise the returned operator will take symbolic array
      arguments.
  
      For a single argument function `func`, `n`-dimensional input array `x` and
      `n`-dimensional 'vector' array `v` of the same shape as `x` then we have
      the following equivalence
  
          hessian_vector_product(func)(x)(v) == tensordot(hessian(func)(x), v, 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[..., Scalar]): Function which takes one or more arrays as
              arguments and returns a scalar.
          wrt (int): Index of argument to take derivatives with respect to.
          return_aux (bool): Whether the generated operator returns the
              Hessian-vector-product function, gradient and value of `func` as a
              3-tuple (True) or just the Hessian-vector-product function (False).
  
      Returns:
          Callable[..., Union[Callable[Array, Array],
                              Tuple[Callable, Array, Scalar]]]:
              Generated Hessian-vector-product operator.
      """