class_docstr: Build optimizer handles
  Args:
      regularizer (object): an `Regularizer` instance
      optimizer (object): an `Optimizer` instance
class_docstr_tok: ["Build","optimizer","handles","Args",":","regularizer","(","object",")",":","an","`","Regularizer","`","instance","optimizer","(","object",")",":","an","`","Optimizer","`","instance"]
code: def __call__(self, learning_rate, model=None):
      if self.clip_grad_by_norm is not None:
          grad_clip = nn.ClipGradByGlobalNorm(
              clip_norm=self.clip_grad_by_norm
          )
      elif self.clip_grad_by_value is not None:
          var = abs(self.clip_grad_by_value)
          grad_clip = nn.ClipGradByValue(min=-var, max=var)
      else:
          grad_clip = None
      if self.regularizer and self.regularizer != "None":
          reg_type = self.regularizer["type"] + "Decay"
          reg_factor = self.regularizer["factor"]
          regularization = getattr(regularizer, reg_type)(reg_factor)
      else:
          regularization = None
  
      optim_args = self.optimizer.copy()
      optim_type = optim_args["type"]
      del optim_args["type"]
  
      if optim_type == "AdamWDL":
          return build_adamwdl(model, lr=learning_rate, **optim_args)
  
      if optim_type != "AdamW":
          optim_args["weight_decay"] = regularization
  
      op = getattr(optimizer, optim_type)
  
      if "param_groups" in optim_args:
          assert isinstance(optim_args["param_groups"], list), ""
  
          param_groups = optim_args.pop("param_groups")
  
          params, visited = [], []
          for group in param_groups:
              assert (
                  isinstance(group, dict)
                  and "params" in group
                  and isinstance(group["params"], list)
              ), ""
              _params = {
                  n: p
                  for n, p in model.named_parameters()
                  if any([k in n for k in group["params"]])
                  and p.trainable is True
              }
              _group = group.copy()
              _group.update({"params": list(_params.values())})
  
              params.append(_group)
              visited.extend(list(_params.keys()))
  
          ext_params = [
              p
              for n, p in model.named_parameters()
              if n not in visited and p.trainable is True
          ]
  
          if len(ext_params) < len(model.parameters()):
              params.append({"params": ext_params})
  
          elif len(ext_params) > len(model.parameters()):
              raise RuntimeError
  
      else:
          _params = model.parameters()
          params = [
              param for param in _params if param.trainable is True
          ]
  
      return op(
          learning_rate=learning_rate,
          parameters=params,
          grad_clip=grad_clip,
          **optim_args,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  import math
  import paddle
  import paddle.nn
  import paddle.optimizer
  import paddle.regularizer
  from ppdet.core.workspace import register, serializable
  import copy
  from .adamw import AdamWDL, build_adamwdl
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 2 for calling the OptimizerBuilder obj's underlying member method code with example usage: obj.__call__(learning_rate, model) and returns: op, build_adamwdl