code: def param_groups_layer_decay(
      model: nn.Module,
      weight_decay: float = 0.05,
      no_weight_decay_list: Tuple[str] = (),
      layer_decay: float = 0.75,
      end_layer_decay: Optional[float] = None,
      verbose: bool = False,
  ):
      """
      Parameter groups for layer-wise lr decay & weight decay
      Based on BEiT: https://github.com/microsoft/unilm/blob/master/beit/optim_factory.py#L58
      """
      no_weight_decay_list = set(no_weight_decay_list)
      param_group_names = {}  # NOTE for debugging
      param_groups = {}
  
      if hasattr(model, "group_matcher"):
          # FIXME interface needs more work
          layer_map = group_parameters(
              model, model.group_matcher(coarse=False), reverse=True
          )
      else:
          # fallback
          layer_map = _layer_map(model)
      num_layers = max(layer_map.values()) + 1
      layer_max = num_layers - 1
      layer_scales = list(
          layer_decay ** (layer_max - i) for i in range(num_layers)
      )
  
      for name, param in model.named_parameters():
          if not param.requires_grad:
              continue
  
          # no decay: all 1D parameters and model specific ones
          if param.ndim == 1 or name in no_weight_decay_list:
              g_decay = "no_decay"
              this_decay = 0.0
          else:
              g_decay = "decay"
              this_decay = weight_decay
  
          layer_id = layer_map.get(name, layer_max)
          group_name = "layer_%d_%s" % (layer_id, g_decay)
  
          if group_name not in param_groups:
              this_scale = layer_scales[layer_id]
              param_group_names[group_name] = {
                  "lr_scale": this_scale,
                  "weight_decay": this_decay,
                  "param_names": [],
              }
              param_groups[group_name] = {
                  "lr_scale": this_scale,
                  "weight_decay": this_decay,
                  "params": [],
              }
  
          param_group_names[group_name]["param_names"].append(name)
          param_groups[group_name]["params"].append(param)
  
      if verbose:
          import json
  
          _logger.info(
              "parameter groups: \n%s"
              % json.dumps(param_group_names, indent=2)
          )
  
      return list(param_groups.values())
  
imports: import logging
  from itertools import islice
  from typing import Optional, Callable, Tuple
  import torch
  import torch.nn
  import torch.optim
  from timm.models import group_parameters
  from .adabelief import AdaBelief
  from .adafactor import Adafactor
  from .adahessian import Adahessian
  from .adamp import AdamP
  from .adan import Adan
  from .lamb import Lamb
  from .lars import Lars
  from .lion import Lion
  from .lookahead import Lookahead
  from .madgrad import MADGRAD
  from .nadam import Nadam
  from .nadamw import NAdamW
  from .nvnovograd import NvNovoGrad
  from .radam import RAdam
  from .rmsprop_tf import RMSpropTF
  from .sgdp import SGDP
  from .sgdw import SGDW
label_desc: Use image node_id 4 for calling a global function with example usage: param_groups_layer_decay(model, weight_decay, no_weight_decay_list, layer_decay, end_layer_decay, verbose) and returns: list