class_docstr: Tests :meth:`FullyShardedDataParallel.clip_grad_norm_`.
docstr: Tests FSDP with ``FullyShardedDataParallel.clip_grad_norm_()` against
  DDP with ``torch.nn.utils.clip_grad_norm_()` when using full precision.
docstr_tok: ["Tests","FSDP","with","``","FullyShardedDataParallel.clip_grad_norm_","(",")","`","against","DDP","with","``","torch.nn.utils.clip_grad_norm_","(",")","`","when","using","full","precision","."]
code: def test_ddp_parity(self):
      """
      Tests FSDP with ``FullyShardedDataParallel.clip_grad_norm_()` against
      DDP with ``torch.nn.utils.clip_grad_norm_()` when using full precision.
      """
      self.run_subtests(
          {
              "max_norm": [1, 2.5],
              "norm_type": [1, 2, float("inf")],
              "sharding_strategy": [
                  ShardingStrategy.FULL_SHARD,
                  ShardingStrategy.NO_SHARD,
                  "mixed_strategy",
              ],
              "use_orig_params": [False, True],
              "offload_params": [False, True],
          },
          self._test_ddp_parity,
      )
  
imports: import itertools
  import sys
  from typing import Union
  import torch
  import torch.nn
  from torch import distributed
  from torch.distributed.fsdp import ShardingStrategy
  from torch.distributed.fsdp.fully_sharded_data_parallel import CPUOffload, FullyShardedDataParallel, MixedPrecision
  from torch.distributed.fsdp.wrap import ModuleWrapPolicy
  from torch.nn import TransformerDecoderLayer, TransformerEncoderLayer
  from torch.nn.parallel import DistributedDataParallel
  from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
  from torch.testing._internal.common_fsdp import CUDAInitMode, FSDPInitMode, FSDPTest, NestedWrappedModule, TransformerWithSharedParams
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, run_tests, TEST_WITH_DEV_DBG_ASAN
label_desc: Use image node_id 2 for calling the TestClipGradNorm obj's underlying member method code with example usage: obj.test_ddp_parity() without return types