class_docstr: Base class for models
class_docstr_tok: ["Base","class","for","models"]
docstr: Get the optimizer according to configuration. Usually we will use Adam.
  
  Returns:
      object: An optimizer.
docstr_tok: ["Get","the","optimizer","according","to","configuration",".","Usually","we","will","use","Adam",".","Returns",":","object",":","An","optimizer","."]
code: def _train_opt(self):
      """Get the optimizer according to configuration. Usually we will use Adam.
  
      Returns:
          object: An optimizer.
      """
      lr = self.hparams.learning_rate
      optimizer = self.hparams.optimizer
  
      if optimizer == "adadelta":
          train_step = tf.compat.v1.train.AdadeltaOptimizer(lr)
      elif optimizer == "adagrad":
          train_step = tf.compat.v1.train.AdagradOptimizer(lr)
      elif optimizer == "sgd":
          train_step = tf.compat.v1.train.GradientDescentOptimizer(lr)
      elif optimizer == "adam":
          train_step = tf.compat.v1.train.AdamOptimizer(lr)
      elif optimizer == "ftrl":
          train_step = tf.compat.v1.train.FtrlOptimizer(lr)
      elif optimizer == "gd":
          train_step = tf.compat.v1.train.GradientDescentOptimizer(lr)
      elif optimizer == "padagrad":
          train_step = tf.compat.v1.train.ProximalAdagradOptimizer(lr)
      elif optimizer == "pgd":
          train_step = (
              tf.compat.v1.train.ProximalGradientDescentOptimizer(lr)
          )
      elif optimizer == "rmsprop":
          train_step = tf.compat.v1.train.RMSPropOptimizer(lr)
      else:
          train_step = tf.compat.v1.train.GradientDescentOptimizer(lr)
      return train_step
  
imports: from os.path import join
  import abc
  import time
  import os
  import numpy
  import tensorflow
  from recommenders.models.deeprec.deeprec_utils import cal_metric
label_desc: Use image node_id 12 for calling the BaseModel obj's underlying member method code with example usage: obj._train_opt() and returns: train_step