code: def make_val_and_grad_fn(value_fn):
      """Function decorator to compute both function value and gradient.
  
      For example:
  
      ```
      @tff.math.make_val_and_grad_fn
      def quadratic(x):
        return tf.reduce_sum(scales * (x - minimum) ** 2, axis=-1)
      ```
  
      Turns `quadratic` into a function that accepts a point as a `Tensor` as input
      and returns a tuple of two `Tensor`s with the value and the gradient of the
      defined quadratic function evaluated at the input point.
  
      This is useful for constructing functions to optimize with tff.math.optimizer
      methods.
  
      Args:
        value_fn: A python function to decorate.
  
      Returns:
        The decorated function.
      """
  
      @functools.wraps(value_fn)
      def val_and_grad(x):
          return value_and_gradient(value_fn, x)
  
      return val_and_grad
  
file_path: tf-quant-finance/tf_quant_finance/math/gradient.py
imports: import functools
  import tensorflow.compat.v2
label_desc: Use image node_id 4 for calling a global function with example usage: make_val_and_grad_fn(value_fn) and returns: val_and_grad, value_and_gradient