code: def testGradientsOfPrune(self):
      v1 = variables.Variable(2.0)
      v2_holder = []
  
      def f(z):
          v2 = variables.Variable(3.0)
          v2_holder.append(v2)
          return array_ops.identity(v1 * v2 * z, "fetch")
  
      f_wrapped = wrap_function.wrap_function(
          f, [tensor_spec.TensorSpec((), dtype=dtypes.float32)]
      )
  
      x = constant_op.constant(1.0)
      with backprop.GradientTape() as tape:
          tape.watch(x)
          out = f_wrapped(x)
      grads = tape.gradient(out, [x, v1, v2_holder[0]])
  
      self.assertAllEqual(6.0, out)
      self.assertAllEqual([6.0, 3.0, 2.0], grads)
  
      pruned = f_wrapped.prune(
          feeds=f_wrapped.inputs,
          fetches=f_wrapped.graph.get_tensor_by_name("fetch:0"),
      )
  
      x = constant_op.constant(1.0)
      with backprop.GradientTape() as tape:
          tape.watch(x)
          out = pruned(x)
      grads = tape.gradient(out, [x, v1, v2_holder[0]])
  
      self.assertAllEqual(6.0, out)
      self.assertAllEqual([6.0, 3.0, 2.0], grads)
  
imports: import os
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.eager import backprop
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import wrap_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import importer
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import state_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.ops import variables
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import test
  from tensorflow.python.training import saver
label_desc: Use image node_id 9 for calling the WrapFunctionTest obj's underlying member method code with example usage: obj.testGradientsOfPrune() and returns: array_ops