code: def get_optimizer_by_name(optimizer_name, learning_rate):
      """
      Get optimizer object by the optimizer name.
  
      Args:
        optimizer_name: Name of the optimizer.
        learning_rate: The learning rate.
  
      Return:
        The optimizer object.
      """
  
      if optimizer_name == "sgd":
          optimizer = tf.train.GradientDescentOptimizer(learning_rate)
      elif optimizer_name == "adadelta":
          optimizer = tf.train.AdadeltaOptimizer(learning_rate)
      elif optimizer_name == "adagrad":
          optimizer = tf.train.AdagradOptimizer(learning_rate)
      elif optimizer_name == "adam":
          optimizer = tf.train.AdamOptimizer(learning_rate)
      elif optimizer_name == "ftrl":
          optimizer = tf.train.FtrlOptimizer(learning_rate)
      elif optimizer_name == "rmsprop":
          optimizer = tf.train.RMSPropOptimizer(learning_rate)
      else:
          optimizer = tf.train.GradientDescentOptimizer(learning_rate)
      return optimizer
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tensorflow.examples.tutorials.mnist import input_data
label_desc: Use image node_id 1 for calling a global function with example usage: get_optimizer_by_name(optimizer_name, learning_rate) and returns: optimizer