docstr: Tests the core usage of``with_grads=True`` by comparing against DDP as
  the unsharded equivalent.
docstr_tok: ["Tests","the","core","usage","of","``","with_grads=True","``","by","comparing","against","DDP","as","the","unsharded","equivalent","."]
code: def test_with_grads_core(self):
      """
      Tests the core usage of``with_grads=True`` by comparing against DDP as
      the unsharded equivalent.
      """
      self.run_subtests(
          {
              "writeback": [False, True],
              "offload_to_cpu": [False, True],
              "sharding_strategy": [
                  ShardingStrategy.FULL_SHARD,
                  ShardingStrategy.SHARD_GRAD_OP,
                  ShardingStrategy.NO_SHARD,
              ],
              "use_orig_params": [True],
          },
          self._test_with_grads_core,
      )
  
imports: import contextlib
  import itertools
  import math
  import sys
  from typing import Any, Dict, List, Optional, Union
  import torch
  import torch.distributed.fsdp._traversal_utils
  import torch.nn
  from torch import distributed
  from torch.distributed.fsdp import CPUOffload, FullyShardedDataParallel, MixedPrecision, ShardingStrategy
  from torch.distributed.fsdp._common_utils import clean_tensor_name
  from torch.distributed.fsdp._flat_param import FlatParameter
  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, FSDPInitMode, FSDPTest, NestedWrappedModule, TransformerWithSharedParams
  from torch.testing._internal.common_utils import run_tests, TEST_WITH_DEV_DBG_ASAN
label_desc: Use image node_id 11 for calling the TestUnshardParams obj's underlying member method code with example usage: obj.test_with_grads_core() without return types