code: def testLinearDecayLearningRate(self):
      with self.test_session() as sess:
          # At step 0 (no offset), the learning rate should be initial_lr.
          spec = LearningRateSpec(
              step=tf.constant(0, tf.int32),
              total_train_steps=100,
              initial_lr=0.001,
              offset=0,
          )
          self.assertAlmostEqual(
              0.001, sess.run(_get_linear_decay_lr(spec))
          )
  
          # Halfway, the learning rate should be initial_lr / 2.
          spec.step = tf.constant(50, tf.int32)
          self.assertAlmostEqual(
              0.0005, sess.run(_get_linear_decay_lr(spec))
          )
  
          # At the end of training it should be 0.
          spec.step = 100
          self.assertAlmostEqual(
              0, sess.run(_get_linear_decay_lr(spec))
          )
  
          # If the 0 > step > offset, then lr should be initial_lr.
          spec.offset = 50
          spec.step = 40
          self.assertAlmostEqual(
              0.001, sess.run(_get_linear_decay_lr(spec))
          )
  
file_path: mesh/mesh_tensorflow/transformer/learning_rate_schedules_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import dataclasses
  from mesh_tensorflow.transformer import learning_rate_schedules
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling the UtilsTest obj's underlying member method code with example usage: obj.testLinearDecayLearningRate() without return types