code: def build_optimizer(
      learning_rate,
      optimizer_name="rmsprop",
      decay=0.9,
      epsilon=0.001,
      momentum=0.9,
  ):
      """Build optimizer."""
      if optimizer_name == "sgd":
          logging.info("Using SGD optimizer")
          optimizer = tf.train.GradientDescentOptimizer(
              learning_rate=learning_rate
          )
      elif optimizer_name == "momentum":
          logging.info("Using Momentum optimizer")
          optimizer = tf.train.MomentumOptimizer(
              learning_rate=learning_rate, momentum=momentum
          )
      elif optimizer_name == "rmsprop":
          logging.info("Using RMSProp optimizer")
          optimizer = tf.train.RMSPropOptimizer(
              learning_rate, decay, momentum, epsilon
          )
      else:
          logging.fatal("Unknown optimizer: %s", optimizer_name)
  
      return optimizer
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import json
  import os
  import sys
  from absl import logging
  import numpy
  import tensorflow.compat.v1
  from tensorflow.python.tpu import tpu_function
label_desc: Use image node_id 2 for calling a global function with example usage: build_optimizer(learning_rate, optimizer_name, decay, epsilon, momentum) and returns: optimizer