class_docstr: Tests optimization.
      
docstr: Tests get_learning_rate_decay_fn.
          
code: def test_get_learning_rate_decay_fn(self):
      """Tests get_learning_rate_decay_fn."""
      default_lr_decay_fn = opt.get_learning_rate_decay_fn(
          opt.default_optimization_hparams()["learning_rate_decay"]
      )
      self.assertIsNone(default_lr_decay_fn)
  
      boundaries = [2, 4]
      values = [0.1, 0.01, 0.001]
      hparams = {
          "type": "piecewise_constant",
          "kwargs": {"boundaries": boundaries, "values": values},
          "min_learning_rate": 0.05,
          "start_decay_step": 1,
          "end_decay_step": utils.MAX_SEQ_LENGTH,
      }
      pc_lr_decay_fn = opt.get_learning_rate_decay_fn(hparams)
  
      global_step = 1
      pc_lr = pc_lr_decay_fn(learning_rate=1.0, global_step=global_step)
      pc_lr_true = tf.train.piecewise_constant(
          global_step - hparams["start_decay_step"], boundaries, values
      )
  
      hparams["type"] = "natural_exp_decay"
      hparams["kwargs"] = {"decay_steps": 1, "decay_rate": 0.5}
      ned_lr_decay_fn = opt.get_learning_rate_decay_fn(hparams)
      ned_lr = ned_lr_decay_fn(
          learning_rate=1.0, global_step=global_step
      )
      ned_lr_true = tf.train.natural_exp_decay(
          1.0,
          global_step - hparams["start_decay_step"],
          hparams["kwargs"]["decay_steps"],
          hparams["kwargs"]["decay_rate"],
      )
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          pc_lr_, pc_lr_true_, ned_lr_, ned_lr_true_ = sess.run(
              [pc_lr, pc_lr_true, ned_lr, ned_lr_true]
          )
          self.assertEqual(pc_lr_, pc_lr_true_)
          self.assertEqual(ned_lr_, ned_lr_true_)
  
file_path: texar/tests/core/optimization_test.py
imports: import numpy
  import tensorflow
  import texar.tf.core.optimization
  from texar.tf.utils import utils
label_desc: Use image node_id 2 for calling the OptimizationTest obj's underlying member method code with example usage: obj.test_get_learning_rate_decay_fn() without return types