docstr: Tests that calling ``apply()`` on an FSDP instance inside the
  ``summon_full_params()`` context raises an error.
docstr_tok: ["Tests","that","calling","``","apply","(",")","``","on","an","FSDP","instance","inside","the","``","summon_full_params","(",")","``","context","raises","an","error","."]
code: def test_apply_in_summon_raises_error(self):
      """Tests that calling ``apply()`` on an FSDP instance inside the
      ``summon_full_params()`` context raises an error."""
      transformer = TransformerWithSharedParams.init(
          self.process_group,
          FSDPInitMode.RECURSIVE,
          CUDAInitMode.CUDA_AFTER,
      )
      with transformer.summon_full_params(transformer):
          with self.assertRaisesRegex(
              ValueError, "expected to be in states"
          ):
              transformer.apply(self._init_linear_weights)
  
file_path: pytorch/test/distributed/fsdp/test_fsdp_apply.py
imports: import sys
  import torch
  import torch.distributed
  import torch.nn
  from torch.distributed.fsdp import FullyShardedDataParallel
  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 7 for calling the TestApply obj's underlying member method code with example usage: obj.test_apply_in_summon_raises_error() without return types