docstr: Tests that passing an FSDP module as an ignored module or the
  top-level module itself errors.
docstr_tok: ["Tests","that","passing","an","FSDP","module","as","an","ignored","module","or","the","top-level","module","itself","errors","."]
code: def test_ignored_modules_invalid(self, composable):
      """Tests that passing an FSDP module as an ignored module or the
      top-level module itself errors."""
      model = Model().cuda()
      wrap_cls = FSDP if composable else fully_shard
      model.layer1 = wrap_cls(model.layer1)
      # Passing an FSDP module as an ignored module should error
      with self.assertRaises(
          ValueError,
          msg="`ignored_modules` should not include FSDP modules",
      ):
          wrap_cls(model, ignored_modules=[model.layer1])
      with self.assertWarnsRegex(
          expected_warning=UserWarning,
          expected_regex="Trying to ignore the top-level module passed into "
          "the FSDP constructor itself will result in all parameters being "
          "ignored",
      ):
          # `fully_shard` does not allow to wrap the same model twice, so create
          # a new local model here.
          new_model = Model().cuda()
          wrap_cls(new_model, ignored_modules=[new_model])
  
imports: import functools
  import math
  import sys
  import torch
  import torch.distributed.fsdp._traversal_utils
  import torch.nn
  from torch import distributed
  from torch.distributed._composable import fully_shard
  from torch.distributed.fsdp import FullyShardedDataParallel
  from torch.distributed.fsdp._common_utils import _get_module_fsdp_state
  from torch.distributed.fsdp.wrap import ModuleWrapPolicy, transformer_auto_wrap_policy
  from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
  from torch.testing._internal.common_fsdp import CUDAInitMode, FSDPInitMode, FSDPTest, TransformerWithSharedParams
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, TEST_WITH_DEV_DBG_ASAN
label_desc: Use image node_id 11 for calling the TestFSDPIgnoredModules obj's underlying member method code with example usage: obj.test_ignored_modules_invalid(composable) without return types