code: def value_and_grad(fn, args):
      """Given `fn: (args) -> out, extra`, returns `dout/dargs`."""
      with tf.GradientTape() as tape:
          args = map_tree(tf.convert_to_tensor, args)
          tape.watch(args)
          ret, extra = fn(args)
      grads = tape.gradient(ret, args)
      return ret, extra, grads
  
imports: import functools
  import numpy
  import six
  import tensorflow.compat.v2
  from tensorflow.python.util import nest
label_desc: Use image node_id 7 for calling a global function with example usage: value_and_grad(fn, args) and returns: ret,  extra,  grads