code: def get_learning_rate_decay_fn(hparams=None):
      """Creates learning rate decay function based on the hyperparameters.
  
      See the :attr:`learning_rate_decay` field in
      :meth:`~texar.tf.core.default_optimization_hparams` for all
      hyperparameters and default values.
  
      Args:
          hparams (dict or HParams, optional): hyperparameters. Missing
              hyperparameters are set to default values automatically.
  
      Returns:
          function or None: If hparams["type"] is specified, returns a
          function that takes `(learning_rate, step, **kwargs)` and
          returns a decayed learning rate. If
          hparams["type"] is empty, returns `None`.
      """
      if hparams is None or isinstance(hparams, dict):
          hparams = HParams(
              hparams,
              default_optimization_hparams()["learning_rate_decay"],
          )
  
      fn_type = hparams["type"]
      if fn_type is None or fn_type == "":
          return None
  
      fn_modules = ["tensorflow.train", "texar.tf.custom"]
      decay_fn = utils.get_function(fn_type, fn_modules)
      fn_kwargs = hparams["kwargs"]
      if fn_kwargs is HParams:
          fn_kwargs = fn_kwargs.todict()
  
      start_step = tf.cast(hparams["start_decay_step"], tf.int32)
      end_step = tf.cast(hparams["end_decay_step"], tf.int32)
  
      def lr_decay_fn(learning_rate, global_step):
          """Learning rate decay function.
  
          Args:
              learning_rate (float or Tensor): The original learning rate.
              global_step (int or scalar int Tensor): optimization step counter.
  
          Returns:
              scalar float Tensor: decayed learning rate.
          """
          offset_global_step = tf.maximum(
              tf.minimum(tf.cast(global_step, tf.int32), end_step)
              - start_step,
              0,
          )
          if decay_fn == tf.train.piecewise_constant:
              decayed_lr = decay_fn(x=offset_global_step, **fn_kwargs)
          else:
              fn_kwargs_ = {
                  "learning_rate": learning_rate,
                  "global_step": offset_global_step,
              }
              fn_kwargs_.update(fn_kwargs)
              decayed_lr = utils.call_function_with_redundant_kwargs(
                  decay_fn, fn_kwargs_
              )
  
              decayed_lr = tf.maximum(
                  decayed_lr, hparams["min_learning_rate"]
              )
  
          return decayed_lr
  
      return lr_decay_fn
  
file_path: texar/texar/tf/core/optimization.py
imports: import re
  import tensorflow
  from texar.tf.hyperparams import HParams
  from texar.tf.utils import utils
label_desc: Use image node_id 3 for calling a global function with example usage: get_learning_rate_decay_fn(hparams) and returns: lr_decay_fn, None, decayed_lr