code: def test_named_params_with_sharded_tensor(self):
      rowwise_spec = ChunkShardingSpec(
          dim=0,
          placements=[
              "rank:0/cuda:0",
              "rank:1/cuda:1",
              "rank:2/cuda:2",
              "rank:3/cuda:3",
          ],
      )
      sharded_model = MyShardedModel(spec=rowwise_spec).cuda()
      sharded_model_params = dict(sharded_model.named_parameters())
      param_keys = list(sharded_model_params.keys())
      self.assertEqual(len(param_keys), 2)
      self.assertTrue("param" in param_keys)
      self.assertTrue("sharded_param" in param_keys)
  
      sharded_linear = MyShardedLinear(rank=self.rank).cuda()
      sharded_linear.shard_parameter()
      sharded_linear_params = dict(sharded_linear.named_parameters())
      param_keys = list(sharded_linear_params.keys())
      self.assertEqual(len(param_keys), 4)
      self.assertTrue("linear1.bias" in param_keys)
      self.assertTrue("linear2.bias" in param_keys)
      self.assertTrue("linear1.weight" in param_keys)
      self.assertTrue("linear2.weight" in param_keys)
      self.assertFalse("bias" in param_keys)
  
imports: import torch
  import torch.optim
  from torch.distributed._shard import sharded_tensor, shard_parameter
  from copy import deepcopy
  from torch.distributed._shard.sharding_spec import ChunkShardingSpec
  from torch.distributed._shard.sharded_optim import ShardedOptimizer
  from torch.testing._internal.common_distributed import requires_nccl, skip_if_lt_x_gpu
  from torch.testing._internal.common_utils import run_tests
  from torch.testing._internal.distributed._shard.sharded_tensor import ShardedTensorTestBase, with_comms
label_desc: Use image node_id 2 for calling the TestShardedOptimizer obj's underlying member method code with example usage: obj.test_named_params_with_sharded_tensor() without return types