class_docstr: Base model.
docstr: Construct the backward of the train program.
  :param loss: `type : variable` final loss of the model.
  :param opt: `type : string` the optimizer name
  :return:
docstr_tok: ["Construct","the","backward","of","the","train","program",".",":","param","loss",":","`","type",":","variable","`","final","loss","of","the","model",".",":","param","opt",":","`","type",":","string","`","the","optimizer","name",":","return",":"]
code: def apply_optimizer(self, loss, opt="sgd"):
      """
      Construct the backward of the train program.
      :param loss: `type : variable` final loss of the model.
      :param opt: `type : string` the optimizer name
      :return:
      """
      optimizer_available = {
          "adam": fluid.optimizer.Adam,
          "sgd": fluid.optimizer.SGD,
          "momentum": fluid.optimizer.Momentum,
      }
      if opt in optimizer_available:
          opt_func = optimizer_available[opt]
      else:
          opt_func = None
      if opt_func is None:
          raise ValueError(
              "You should chose the optimizer in %s"
              % optimizer_available.keys()
          )
      else:
          optimizer = opt_func(learning_rate=self._learning_rate)
          return optimizer.minimize(loss)
  
file_path: PGL/legacy/examples/pgl-ke/model/Model.py
imports: from paddle import fluid
label_desc: Use image node_id 3 for calling the Model obj's underlying member method code with example usage: obj.apply_optimizer(loss, opt) and returns: optimizer