code: def value_and_grad(fun, x):
      """Returns a function that returns both value and gradient. Suitable for use
      in scipy.optimize"""
      vjp, ans = _make_vjp(fun, x)
      if not vspace(ans).size == 1:
          raise TypeError(
              "value_and_grad only applies to real scalar-output "
              "functions. Try jacobian, elementwise_grad or "
              "holomorphic_grad."
          )
      return ans, vjp(vspace(ans).ones())
  
imports: from __future__ import absolute_import
  from functools import partial
  from collections import OrderedDict
  import warnings
  from .wrap_util import unary_to_nary
  from .builtins import tuple
  from .core import make_vjp, make_jvp
  from .extend import primitive, defvjp_argnum, vspace
  import autograd.numpy
label_desc: Use image node_id 13 for calling a global function with example usage: value_and_grad(fun, x) and returns: ans,  vjp