class_docstr: Base class for all optimizers.
  
  .. warning::
      Parameters need to be specified as collections that have a deterministic
      ordering that is consistent between runs. Examples of objects that don't
      satisfy those properties are sets and iterators over values of dictionaries.
  
  Args:
      params (iterable): an iterable of :class:`torch.Tensor` s or
          :class:`dict` s. Specifies what Tensors should be optimized.
      defaults: (dict): a dict containing default values of optimization
          options (used when a parameter group doesn't specify them).
class_docstr_tok: ["Base","class","for","all","optimizers",".","..","warning",":",":","Parameters","need","to","be","specified","as","collections","that","have","a","deterministic","ordering","that","is","consistent","between","runs",".","Examples","of","objects","that","don't","satisfy","those","properties","are","sets","and","iterators","over","values","of","dictionaries",".","Args",":","params","(","iterable",")",":","an","iterable","of",":","class",":","`","torch.Tensor","`","s","or",":","class",":","`","dict","`","s.","Specifies","what","Tensors","should","be","optimized",".","defaults",":","(","dict",")",":","a","dict","containing","default","values","of","optimization","options","(","used","when","a","parameter","group","does","n't","specify","them",")","."]
docstr: Add a param group to the :class:`Optimizer` s `param_groups`.
  
  This can be useful when fine tuning a pre-trained network as frozen layers can be made
  trainable and added to the :class:`Optimizer` as training progresses.
  
  Args:
      param_group (dict): Specifies what Tensors should be optimized along with group
          specific optimization options.
docstr_tok: ["Add","a","param","group","to","the",":","class",":","`","Optimizer","`","s","`","param_groups","`",".","This","can","be","useful","when","fine","tuning","a","pre-trained","network","as","frozen","layers","can","be","made","trainable","and","added","to","the",":","class",":","`","Optimizer","`","as","training","progresses",".","Args",":","param_group","(","dict",")",":","Specifies","what","Tensors","should","be","optimized","along","with","group","specific","optimization","options","."]
code: def add_param_group(self, param_group: Dict[str, Any]) -> None:
      r"""Add a param group to the :class:`Optimizer` s `param_groups`.
  
      This can be useful when fine tuning a pre-trained network as frozen layers can be made
      trainable and added to the :class:`Optimizer` as training progresses.
  
      Args:
          param_group (dict): Specifies what Tensors should be optimized along with group
              specific optimization options.
      """
      if not isinstance(param_group, dict):
          raise TypeError(
              f"param_group must be a dict, but got {type(param_group)}"
          )
  
      params = param_group["params"]
      if isinstance(params, torch.Tensor):
          param_group["params"] = [params]
      elif isinstance(params, set):
          raise TypeError(
              "optimizer parameters need to be organized in ordered collections, but "
              "the ordering of tensors in sets will change between runs. Please use a list instead."
          )
      else:
          param_group["params"] = list(params)
  
      for param in param_group["params"]:
          if not isinstance(param, torch.Tensor):
              raise TypeError(
                  "optimizer can only optimize Tensors, "
                  "but one of the params is " + torch.typename(param)
              )
          if not self.defaults.get("differentiable", None) and not (
              param.is_leaf or param.retains_grad
          ):
              raise ValueError("can't optimize a non-leaf Tensor")
  
      for name, default in self.defaults.items():
          if default is required and name not in param_group:
              raise ValueError(
                  f"parameter group didn't specify a value of required optimization parameter {name}"
              )
          else:
              param_group.setdefault(name, default)
  
      params = param_group["params"]
      if len(params) != len(set(params)):
          warnings.warn(
              "optimizer contains a parameter group with duplicate parameters; "
              "in future, this will cause an error; "
              "see github.com/pytorch/pytorch/issues/40967 for more information",
              stacklevel=3,
          )
  
      param_set: Set[torch.Tensor] = set()
      for group in self.param_groups:
          param_set.update(set(group["params"]))
  
      if not param_set.isdisjoint(set(param_group["params"])):
          raise ValueError(
              "some parameters appear in more than one parameter group"
          )
  
      self.param_groups.append(param_group)
  
imports: import math
  import functools
  import warnings
  from collections import OrderedDict, defaultdict
  from copy import deepcopy
  from itertools import chain
  from typing import Any, Callable, DefaultDict, Dict, Hashable, Iterable, List, Optional, Set, Tuple, TypeVar, Union, cast, overload
  from typing_extensions import ParamSpec, Self, TypeAlias
  import torch
  import torch.utils.hooks
  from torch.utils.hooks import RemovableHandle
  from torch.utils._foreach_utils import Indices, TensorListList, _get_foreach_kernels_supported_devices, _get_fused_kernels_supported_devices
  from torch._utils import is_compiling
  from torch.utils._foreach_utils import _group_tensors_by_device_and_dtype
label_desc: Use image node_id 23 for calling the Optimizer obj's underlying member method code with example usage: obj.add_param_group(param_group) without return types