code: def testCollectionsIsolation(self):
      v1 = variables.Variable(2.0)
      v2_holder = []
  
      def f():
          v2 = variables.Variable(3.0)
          v2_holder.append(v2)
          ops.add_to_collection(
              ops.GraphKeys.LOSSES, v2 * constant_op.constant(3.0)
          )
          return array_ops.identity(
              v1 * v2 * constant_op.constant(1.0), "fetch"
          )
  
      f_wrapped = wrap_function.wrap_function(f, [])
      self.assertAllEqual(6.0, f_wrapped())
      self.assertEqual(
          len(f_wrapped.graph.get_collection(ops.GraphKeys.LOSSES)), 1
      )
      f_var_collection = f_wrapped.graph.get_collection(
          ops.GraphKeys.TRAINABLE_VARIABLES
      )
      self.assertEqual(len(f_var_collection), 1)
      self.assertIs(f_var_collection[0], v2_holder[0])
  
      v3_holder = []
  
      def g():
          v3 = variables.Variable(4.0)
          v3_holder.append(v3)
          ops.add_to_collection(
              ops.GraphKeys.LOSSES, v3 * constant_op.constant(3.0)
          )
          return array_ops.identity(
              v1 * v3 * constant_op.constant(1.0), "fetch"
          )
  
      g_wrapped = wrap_function.wrap_function(g, [])
      self.assertAllEqual(8.0, g_wrapped())
      self.assertEqual(
          len(g_wrapped.graph.get_collection(ops.GraphKeys.LOSSES)), 1
      )
      g_var_collection = g_wrapped.graph.get_collection(
          ops.GraphKeys.TRAINABLE_VARIABLES
      )
      self.assertEqual(len(g_var_collection), 1)
      self.assertIs(g_var_collection[0], v3_holder[0])
  
      # Both have only one value, and their values aren't equal. So no sharing.
      self.assertIsNot(
          g_wrapped.graph.get_collection(ops.GraphKeys.LOSSES[0]),
          f_wrapped.graph.get_collection(ops.GraphKeys.LOSSES)[0],
      )
  
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 8 for calling the WrapFunctionTest obj's underlying member method code with example usage: obj.testCollectionsIsolation() and returns: array_ops, array_ops