code: def build_optimizer(name, lr=0.001, **kwargs):
      """Get an optimizer for TensorFlow high-level API Estimator.
  
      Available options are: `adadelta`, `adagrad`, `adam`, `ftrl`, `momentum`, `rmsprop` or `sgd`.
  
      Args:
          name (str): Optimizer name.
          lr (float): Learning rate
          kwargs: Optimizer arguments as key-value pairs
  
      Returns:
          tf.train.Optimizer: Tensorflow optimizer.
      """
      name = name.lower()
  
      try:
          optimizer_class = OPTIMIZERS[name]
      except KeyError:
          raise KeyError(
              "Optimizer name should be one of: {}".format(
                  list(OPTIMIZERS)
              )
          )
  
      # Set parameters
      params = {}
      if name == "ftrl":
          params["l1_regularization_strength"] = kwargs.get(
              "l1_regularization_strength", 0.0
          )
          params["l2_regularization_strength"] = kwargs.get(
              "l2_regularization_strength", 0.0
          )
      elif name == "momentum" or name == "rmsprop":
          params["momentum"] = kwargs.get("momentum", 0.0)
  
      return optimizer_class(learning_rate=lr, **params)
  
imports: import itertools
  import numpy
  import tensorflow
  from tensorflow_estimator.python.estimator.export.export import build_supervised_input_receiver_fn_from_input_fn
label_desc: Use image node_id 4 for calling a global function with example usage: build_optimizer(name, lr) and returns: optimizer_class