code: def test_fsdp_ddp_parity_with_grad_scaler(
      self,
      cpu_offload: CPUOffload,
      sharding_strategy: Optional[ShardingStrategy],
      mixed_precision: Optional[str],
      use_orig_params: Optional[str],
  ):
      init_modes = self._get_init_modes_for_test(cpu_offload)
      mp = (
          MixedPrecision(
              param_dtype=torch.float16,
              reduce_dtype=torch.float16,
              buffer_dtype=torch.float16,
          )
          if mixed_precision is not None
          else None
      )
      # the ``NonUniformReqGradNWM`` model requires we set `init_scale`
      # more conservatively than default to avoid infs with the initial steps
      if use_orig_params == "enable_use_orig_params":
          use_orig = True
          model_cls = NonUniformReqGradNWM
          sharded_grad_scaler_kwargs = {"init_scale": 2.0**11}
      else:
          use_orig = False
          model_cls = NestedWrappedModule  # type: ignore[assignment]
          sharded_grad_scaler_kwargs = None
      for cuda_init_mode in init_modes:
          self._test_fsdp_parity(
              model_cls,
              FSDPInitMode.RECURSIVE,
              cuda_init_mode=cuda_init_mode,
              cpu_offload=cpu_offload,
              sharding_strategy=sharding_strategy,
              mixed_precision=mp,
              enable_sharded_grad_scaler=True,
              use_orig_params=use_orig,
              sharded_grad_scaler_kwargs=sharded_grad_scaler_kwargs,
          )
  
imports: import copy
  import functools
  import itertools
  import sys
  import unittest
  from typing import List, Optional
  import torch
  from torch import distributed
  from torch.cuda.amp.common import amp_definitely_not_available
  from torch.distributed.fsdp import CPUOffload, MixedPrecision
  from torch.distributed.fsdp.fully_sharded_data_parallel import FullyShardedDataParallel, ShardingStrategy
  from torch.distributed.fsdp.sharded_grad_scaler import ShardedGradScaler
  from torch.distributed.fsdp.wrap import ModuleWrapPolicy
  from torch.nn import TransformerDecoderLayer, TransformerEncoderLayer
  from torch.nn.parallel.distributed import DistributedDataParallel
  from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
  from torch.testing._internal.common_fsdp import CUDAInitMode, DummyProcessGroup, FSDPInitMode, FSDPTest, NestedWrappedModule, NonUniformReqGradNWM, subtest_name, TransformerWithSharedParams
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, TEST_WITH_DEV_DBG_ASAN, TestCase
label_desc: Use image node_id 2 for calling the TestShardedGradScalerParityWithDDP obj's underlying member method code with example usage: obj.test_fsdp_ddp_parity_with_grad_scaler(cpu_offload, sharding_strategy, mixed_precision, use_orig_params) without return types