code: def hessian(func, argnums=0):
      """
      Computes the Hessian of ``func`` with respect to the arg(s) at index
      ``argnum`` via a forward-over-reverse strategy.
  
      The forward-over-reverse strategy (composing ``jacfwd(jacrev(func))``) is
      a good default for good performance. It is possible to compute Hessians
      through other compositions of :func:`jacfwd` and :func:`jacrev` like
      ``jacfwd(jacfwd(func))`` or ``jacrev(jacrev(func))``.
  
      Args:
          func (function): A Python function that takes one or more arguments,
              one of which must be a Tensor, and returns one or more Tensors
          argnums (int or Tuple[int]): Optional, integer or tuple of integers,
              saying which arguments to get the Hessian with respect to.
              Default: 0.
  
      Returns:
          Returns a function that takes in the same inputs as ``func`` and
          returns the Hessian of ``func`` with respect to the arg(s) at
          ``argnums``.
  
      .. note::
          You may see this API error out with "forward-mode AD not implemented
          for operator X". If so, please file a bug report and we will prioritize it.
          An alternative is to use ``jacrev(jacrev(func))``, which has better
          operator coverage.
  
      A basic usage with a R^N -> R^1 function gives a N x N Hessian:
  
          >>> from torch.func import hessian
          >>> def f(x):
          >>>   return x.sin().sum()
          >>>
          >>> x = torch.randn(5)
          >>> hess = hessian(f)(x)  # equivalent to jacfwd(jacrev(f))(x)
          >>> assert torch.allclose(hess, torch.diag(-x.sin()))
  
      """
      return jacfwd(jacrev(func, argnums), argnums)
  
imports: from typing import Callable, Union, Tuple, List, Any, Optional
  import torch
  from functools import partial, wraps
  import contextlib
  from torch.utils._pytree import tree_flatten, tree_unflatten, tree_map, tree_map_only, tree_map_, treespec_pprint
  from torch.utils import _pytree
  from torch.fx.experimental import const_fold
  from torch.fx.experimental.proxy_tensor import make_fx
  import torch.autograd.forward_ad
  from torch._subclasses.functional_tensor import FunctionalTensor
  from .vmap import doesnt_support_saved_tensors_hooks, get_chunk_sizes
  from .apis import vmap
  from torch._C._functorch import _wrap_for_grad, _unwrap_for_grad, _grad_increment_nesting, _grad_decrement_nesting, _jvp_increment_nesting, _jvp_decrement_nesting, _wrap_functional_tensor, _unwrap_functional_tensor, _func_decrement_nesting, _func_increment_nesting, _assert_wrapped_functional, _propagate_functional_input_mutation, set_inplace_requires_grad_allowed, get_inplace_requires_grad_allowed
  from torch._functorch.utils import exposed_in, argnums_t
label_desc: Use image node_id 33 for calling a global function with example usage: hessian(func, argnums) and returns: jacfwd