class_docstr: Tests ``fully_shard`` initialization.
class_docstr_tok: ["Tests","``","fully_shard","``","initialization","."]
docstr: Tests passing a ``device_id``.
docstr_tok: ["Tests","passing","a","``","device_id","``","."]
code: def test_device_id(self):
      """Tests passing a ``device_id``."""
      cpu_device = torch.device("cpu")
      composable_module = CompositeParamModel(device=cpu_device)
      for param in composable_module.parameters():
          assert (
              param.device == cpu_device
          ), "Expects module to be initialized on CPU for this unit test"
      fully_shard(
          composable_module,
          policy=ModuleWrapPolicy({UnitModule}),
          device_id=self.rank,
      )
      for param in composable_module.parameters():
          self.assertEqual(
              param.device, torch.device("cuda", self.rank)
          )
  
imports: import copy
  import sys
  from typing import Optional
  import torch
  import torch.distributed
  import torch.distributed.fsdp._traversal_utils
  import torch.nn
  from torch.distributed._composable import fully_shard
  from torch.distributed.fsdp import BackwardPrefetch, FullyShardedDataParallel
  from torch.distributed.fsdp._common_utils import _is_fsdp_flattened, clean_tensor_name
  from torch.distributed.fsdp.wrap import _Policy, CustomPolicy, ModuleWrapPolicy
  from torch.testing._internal.common_dist_composable import CompositeParamModel, FakeSequential, NestedSequentialModel, UnitModule
  from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
  from torch.testing._internal.common_fsdp import FSDPTest
  from torch.testing._internal.common_utils import run_tests, TEST_WITH_DEV_DBG_ASAN
label_desc: Use image node_id 6 for calling the TestInitialization obj's underlying member method code with example usage: obj.test_device_id() without return types