code: def group_parameters_for_optimizer(
      model: torch.nn.Module,
      weight_decay: Optional[float] = 0,
      no_decay: Tuple[str, ...] = ("bias", "LayerNorm.weight"),
  ) -> List[Dict[str, Any]]:
      """
      Group parameters by whether weight_decay is applied or not.
  
      Args:
          model: model supplying the learnable parameters
          weight_decay: value for weight_decay
          no_decay: variable names that should not have weight_decay applied
      Returns:
          grouped parameters according to whether weight_decay should be applied
      """
      return [
          {
              "params": [
                  p
                  for n, p in model.named_parameters()
                  if not any(nd in n for nd in no_decay)
              ],
              "weight_decay": weight_decay,
          },
          {
              "params": [
                  p
                  for n, p in model.named_parameters()
                  if any(nd in n for nd in no_decay)
              ],
              "weight_decay": 0.0,
          },
      ]
  
file_path: determined/model_hub/model_hub/huggingface/_trial.py
imports: import dataclasses
  import logging
  from typing import Any, Dict, List, Optional, Tuple, Union, cast
  import datasets
  import torch
  import transformers
  import transformers.optimization
  import determined.pytorch
  from model_hub import utils
  from model_hub.huggingface import _config_parser
label_desc: Use image node_id 2 for calling a global function with example usage: group_parameters_for_optimizer(model, weight_decay, no_decay) and returns: list