code: def testManyFunctions(self, size, same_value):
      r = range(100)
  
      values = [
          np.reshape(r[i : i + size], (4, size // 4)) for i in range(10)
      ]
      c_layout = Layout.replicated(self.mesh, rank=2)
      values = [
          constant_op.constant(v, dtype=dtypes.float32) for v in values
      ]
      c0 = [api.copy_to_mesh(v, c_layout) for v in values]
  
      c0 = [c0[0 if same_value else i] for i in range(10)]
      e0 = [values[0 if same_value else i] for i in range(10)]
      stats1 = api._dtensor_device()._get_stats()
  
      for i in range(10):
          # Use a special to ensure no conflicts with otherwise used names.
          @polymorphic_function.function
          def fn_31415926(c):
              return math_ops.reduce_sum(c)
  
          self.assertAllEqual(fn_31415926(c0[i]).numpy(), np.sum(e0[i]))
  
      del fn_31415926
      gc.collect()
  
      stats2 = api._dtensor_device()._get_stats()
      diff = diff_dicts(stats2, stats1)
      self.assertEqual(diff["function_manager.size"], 0)
      self.assertEqual(diff["kernel_cache.size"], 0)
      self.assertEqual(diff["device_cache.size"], 0)
  
imports: import gc
  import numpy
  from tensorflow.dtensor.python import api
  from tensorflow.dtensor.python import d_variable
  from tensorflow.dtensor.python import layout
  from tensorflow.dtensor.python.tests import test_util
  from tensorflow.python.eager.polymorphic_function import polymorphic_function
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_stateless_random_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 7 for calling the DTensorDeviceCacheTest obj's underlying member method code with example usage: obj.testManyFunctions(size, same_value) and returns: math_ops