class_docstr: Stores a constituency model and its optimizer
class_docstr_tok: ["Stores","a","constituency","model","and","its","optimizer"]
code: def build_optimizer(model, args):
      if args.optim.lower() == "sgd":
          optimizer = optim.SGD(
              model.parameters(),
              lr=args.learning_rate,
              momentum=args.momentum,
              weight_decay=args.weight_decay,
          )
      elif args.optim.lower() == "adadelta":
          optimizer = optim.Adadelta(
              model.parameters(),
              lr=args.learning_rate,
              weight_decay=args.weight_decay,
          )
      elif args.optim.lower() == "madgrad":
          try:
              import madgrad
          except ModuleNotFoundError as e:
              raise ModuleNotFoundError(
                  "Could not create madgrad optimizer.  Perhaps the madgrad package is not installed"
              ) from e
          optimizer = madgrad.MADGRAD(
              model.parameters(),
              lr=args.learning_rate,
              weight_decay=args.weight_decay,
              momentum=args.momentum,
          )
      else:
          raise ValueError("Unknown optimizer: %s" % args.optim)
      return optimizer
  
file_path: stanza/stanza/models/classifiers/trainer.py
imports: import logging
  import os
  import torch
  import torch.optim
  import stanza.models.classifiers.data
  import stanza.models.classifiers.cnn_classifier
  import stanza.models.classifiers.constituency_classifier
  from stanza.models.classifiers.utils import ModelType
  from stanza.models.common.foundation_cache import load_bert, load_charlm, load_pretrain
  from stanza.models.common.pretrain import Pretrain
  from stanza.models.constituency.tree_embedding import TreeEmbedding
label_desc: Use image node_id 6 for calling the Trainer obj's underlying member method code with example usage: obj.build_optimizer(model, args) and returns: optimizer