code: def before_train(self):
      parameters = []
      params = {"lr": self.lr, "weight_decay": 1e-2}
      params["params"] = [
          param
          for name, param in self.model.named_parameters()
          if not ("bart_encoder" in name or "bart_decoder" in name)
      ]
      parameters.append(params)
  
      params = {"lr": self.lr, "weight_decay": 1e-2}
      params["params"] = []
      for name, param in self.model.named_parameters():
          if (
              "bart_encoder" in name or "bart_decoder" in name
          ) and not ("layernorm" in name or "layer_norm" in name):
              params["params"].append(param)
      parameters.append(params)
  
      params = {"lr": self.lr, "weight_decay": 0}
      params["params"] = []
      for name, param in self.model.named_parameters():
          if ("bart_encoder" in name or "bart_decoder" in name) and (
              "layernorm" in name or "layer_norm" in name
          ):
              params["params"].append(param)
      parameters.append(params)
  
      self.optimizer = optim.AdamW(parameters)
  
      if self.args.freeze_plm:  # freeze pretrained language model(bart)
          for name, par in self.model.named_parameters():
              if (
                  "prompt_encoder" in name
                  or "prompt_decoder" in name
                  and "bart_mlp" not in name
              ):
                  par.requires_grad = False
  
      self.model.to(self.device)
  
file_path: DeepKE/src/deepke/name_entity_re/few_shot/module/train.py
imports: import torch
  from torch import optim
  from tqdm import tqdm
  from ..utils import convert_preds_to_outputs, write_predictions
  import random
label_desc: Use image node_id 6 for calling the Trainer obj's underlying member method code with example usage: obj.before_train() without return types