class_docstr: Base optimizer in PaddleSeg.
  
  Args:
      weight_decay(float, optional): A float value as coeff of L2 regularization.
      grad_clip_cfg(dict, optional): A dict to specify grad_clip. It must have the following format: 
          {'name': 'ClipGradByGlobalNorm', 'clip_norm': float_val},
          {'name': 'ClipGradByNorm', 'clip_norm': float_val},
          {'name': 'ClipGradByValue', 'max': float_val, 'min': float_val(optional)}.
      custom_cfg(list, optional): custom_cfg specify different options for
          different parameter groups such as the learning rate and weight decay.
          For example, [{'name': 'backbone', 'lr_mult': 0.1}, {'name': 'norm', 'weight_decay_mult': 0}]
  
  An example in config:
  `
  optimizer:
    type: SGD
    weight_decay: 4.0e-5
    custom_cfg:
      - name: backbone
        lr_mult: 0.1
      - name: norm
        weight_decay_mult: 0.0
    grad_clip_cfg:
      name: ClipGradByValue
      max: 1.0
  `
class_docstr_tok: ["Base","optimizer","in","PaddleSeg",".","Args",":","weight_decay","(","float",",","optional",")",":","A","float","value","as","coeff","of","L2","regularization",".","grad_clip_cfg","(","dict",",","optional",")",":","A","dict","to","specify","grad_clip",".","It","must","have","the","following","format",":","{","'name","'",":","'ClipGradByGlobalNorm","'",",","'clip_norm","'",":","float_val","}",",","{","'name","'",":","'ClipGradByNorm","'",",","'clip_norm","'",":","float_val","}",",","{","'name","'",":","'ClipGradByValue","'",",","'max","'",":","float_val",",","'min","'",":","float_val","(","optional",")","}",".","custom_cfg","(","list",",","optional",")",":","custom_cfg","specify","different","options","for","different","parameter","groups","such","as","the","learning","rate","and","weight","decay",".","For","example",",","[","{","'name","'",":","'backbone","'",",","'lr_mult","'",":","0.1","}",",","{","'name","'",":","'norm","'",",","'weight_decay_mult","'",":","0","}","]","An","example","in","config",":","`","optimizer",":","type",":","SGD","weight_decay",":","4.0e-5","custom_cfg",":","-","name",":","backbone","lr_mult",":","0.1","-","name",":","norm","weight_decay_mult",":","0.0","grad_clip_cfg",":","name",":","ClipGradByValue","max",":","1.0","`"]
code: def _collect_params(self, model):
      # Collect different parameter groups
      if self.custom_cfg is None or len(self.custom_cfg) == 0:
          return model.parameters()
  
      groups_num = len(self.custom_cfg) + 1
      params_list = [[] for _ in range(groups_num)]
      for name, param in model.named_parameters():
          if param.stop_gradient:
              continue
          for idx, item in enumerate(self.custom_cfg):
              if item["name"] in name:
                  params_list[idx].append(param)
                  break
          else:
              params_list[-1].append(param)
  
      res = []
      for idx, item in enumerate(self.custom_cfg):
          lr_mult = item.get("lr_mult", 1.0)
          weight_decay_mult = item.get("weight_decay_mult", None)
          param_dict = {
              "params": params_list[idx],
              "learning_rate": lr_mult,
          }
          if (
              self.weight_decay is not None
              and weight_decay_mult is not None
          ):
              param_dict["weight_decay"] = (
                  self.weight_decay * weight_decay_mult
              )
          res.append(param_dict)
      res.append({"params": params_list[-1]})
  
      msg = "Parameter groups for optimizer: \n"
      for idx, item in enumerate(self.custom_cfg):
          params_name = [p.name for p in params_list[idx]]
          item = item.copy()
          item["params_name"] = params_name
          msg += "Group {}: \n{} \n".format(idx, item)
      msg += "Last group:\n params_name: {}".format(
          [p.name for p in params_list[-1]]
      )
      logger.info(msg)
  
      return res
  
imports: import paddle
  from paddleseg.cvlibs import manager
  from paddleseg.utils import logger
  import paddleseg.optimizers.custom_optimizers
label_desc: Use image node_id 3 for calling the BaseOptimizer obj's underlying member method code with example usage: obj._collect_params(model) and returns: res, model