code: def _test_apply_optimizer_in_backward(self, share_params) -> None:
      weight_optimizer_kwargs = {"lr": 1.0}
      bias_optimizer_kwargs = {"lr": 0.5}
      model = nn.Sequential(nn.Linear(10, 10), nn.Linear(10, 10))
      if share_params:
          model[0].weight = model[1].weight
  
      # Use different optimizers for weights & biases.
      weights = [m.weight for m in model]
      biases = [m.bias for m in model]
      optim_weight = torch.optim.SGD(weights, **weight_optimizer_kwargs)
      optim_bias = torch.optim.SGD(biases, **bias_optimizer_kwargs)
      model_with_opt_in_bwd = deepcopy(model)
  
      # Apply different optimizer in backwards for weights and biases.
      _apply_optimizer_in_backward(
          torch.optim.SGD,
          [m.weight for m in model_with_opt_in_bwd],
          optimizer_kwargs=weight_optimizer_kwargs,
      )
  
      _apply_optimizer_in_backward(
          torch.optim.SGD,
          [m.bias for m in model_with_opt_in_bwd],
          optimizer_kwargs=bias_optimizer_kwargs,
      )
  
      _validate_params(
          [
              model.parameters(),
              model_with_opt_in_bwd.parameters(),
          ],
          torch.testing.assert_allclose,
      )
  
      self._run_training_loop_and_validate(
          torch.randn(4, 10),
          [model, model_with_opt_in_bwd],
          [optim_weight, optim_bias],
      )
  
file_path: pytorch/test/distributed/optim/test_apply_optimizer_in_backward.py
imports: import unittest
  from copy import deepcopy
  import torch
  import torch.nn
  from torch.distributed.optim import _apply_optimizer_in_backward, _get_in_backward_optimizers
label_desc: Use image node_id 2 for calling the ApplyOverlappedOptimizerTest obj's underlying member method code with example usage: obj._test_apply_optimizer_in_backward(share_params) without return types