code: def testDiet(self):
      params = diet.diet_adam_optimizer_params()
  
      @diet.fn_with_diet_vars(params)
      def model_fn(x):
          y = tf.layers.dense(x, 10, use_bias=False)
          return y
  
      @diet.fn_with_diet_vars(params)
      def model_fn2(x):
          y = tf.layers.dense(x, 10, use_bias=False)
          return y
  
      x = tf.random_uniform((10, 10))
      y = model_fn(x) + 10.0
      y = model_fn2(y) + 10.0
      grads = tf.gradients(y, [x])
      with tf.control_dependencies(grads):
          incr_step = tf.assign_add(
              tf.train.get_or_create_global_step(), 1
          )
  
      train_op = tf.group(incr_step, *grads)
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          orig_vals = sess.run(tf.global_variables())
          for _ in range(10):
              sess.run(train_op)
          new_vals = sess.run(tf.global_variables())
  
          different = []
          for old, new in zip(orig_vals, new_vals):
              try:
                  self.assertAllClose(old, new)
              except AssertionError:
                  different.append(True)
          self.assertEqual(len(different), len(tf.global_variables()))
  
file_path: tensor2tensor/tensor2tensor/utils/diet_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensor2tensor.utils import diet
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling the DietVarTest obj's underlying member method code with example usage: obj.testDiet() and returns: y, y