code: def test_add_param_group(self):
      m = TestDummyModel()
      m_dup = TestDummyModel()
      optim = torch.optim.SGD(
          [
              {"params": m.net1.parameters()},
              {"params": m.net3.parameters(), "lr": 1e-3},
          ],
          lr=1e-2,
          momentum=0.9,
      )
      named_optim = _NamedOptimizer(
          m_dup.named_parameters(),
          torch.optim.SGD,
          [
              {"params": m_dup.net1.parameters()},
              {"params": m_dup.net3.parameters(), "lr": 1e-3},
          ],
          lr=1e-2,
          momentum=0.9,
      )
  
      _run_model_training([(m, [optim]), (m_dup, [named_optim])])
      self._compare_param_groups(
          optim.param_groups, named_optim.param_groups
      )
  
      optim.add_param_group({"params": m.net2.parameters(), "lr": 1e-5})
      named_optim.add_param_group(
          {"params": m_dup.net2.parameters(), "lr": 1e-5}
      )
      _run_model_training([(m, [optim]), (m_dup, [named_optim])])
      self._compare_param_groups(
          optim.param_groups, named_optim.param_groups
      )
  
      optim.add_param_group({"params": m.net4[1].weight, "lr": 1e-3})
      named_optim.add_param_group(
          {"params": m_dup.net4[1].weight, "lr": 1e-3}
      )
      _run_model_training([(m, [optim]), (m_dup, [named_optim])])
      self._compare_param_groups(
          optim.param_groups, named_optim.param_groups
      )
  
imports: import unittest
  import torch
  import torch.nn
  from torch.distributed.optim import _NamedOptimizer
label_desc: Use image node_id 9 for calling the NamedOptimizerTest obj's underlying member method code with example usage: obj.test_add_param_group() without return types