class_docstr: Transformers base model (for working with pytorch-transformers models)
class_docstr_tok: ["Transformers","base","model","(","for","working","with","pytorch-transformers","models",")"]
code: def setup_default_optimizer(
      self,
      weight_decay: float = 0.0,
      learning_rate: float = 5e-5,
      adam_epsilon: float = 1e-8,
      warmup_steps: int = 0,
      total_steps: int = 0,
  ):
      # Prepare optimizer and schedule (linear warmup and decay)
      no_decay = ["bias", "LayerNorm.weight"]
      optimizer_grouped_parameters = [
          {
              "params": [
                  p
                  for n, p in self.model.named_parameters()
                  if not any(nd in n for nd in no_decay)
              ],
              "weight_decay": weight_decay,
          },
          {
              "params": [
                  p
                  for n, p in self.model.named_parameters()
                  if any(nd in n for nd in no_decay)
              ],
              "weight_decay": 0.0,
          },
      ]
      self.optimizer = AdamW(
          optimizer_grouped_parameters,
          lr=learning_rate,
          eps=adam_epsilon,
      )
      self.scheduler = get_linear_schedule_with_warmup(
          self.optimizer,
          num_warmup_steps=warmup_steps,
          num_training_steps=total_steps,
      )
  
imports: import io
  import logging
  import os
  from typing import List, Union
  import torch
  from torch.utils.data import DataLoader
  from tqdm import tqdm, trange
  from transformers import AdamW, BertConfig, BertTokenizer, RobertaConfig, RobertaTokenizer, XLMConfig, XLMTokenizer, XLNetConfig, XLNetTokenizer, get_linear_schedule_with_warmup
  from nlp_architect.models import TrainableModel
  from nlp_architect.models.transformers.quantized_bert import QuantizedBertConfig
label_desc: Use image node_id 7 for calling the TransformerBase obj's underlying member method code with example usage: obj.setup_default_optimizer(weight_decay, learning_rate, adam_epsilon, warmup_steps, total_steps) without return types