code: def test_sharded_tensor_state_dict(single_process_pg):
      from torch.distributed._shard.sharded_tensor import (
          empty as sharded_tensor_empty,
      )
      from torch.distributed._sharding_spec import ChunkShardingSpec
  
      class BoringModelWithShardedTensor(BoringModel):
          def __init__(self, spec):
              super().__init__()
              self.sharded_tensor = sharded_tensor_empty(spec, 10, 20)
              self.sharded_tensor.local_shards()[0].tensor.fill_(0)
  
      spec = ChunkShardingSpec(
          dim=0,
          placements=[
              "rank:0/cpu",
          ],
      )
  
      m_0 = BoringModelWithShardedTensor(spec)
      m_0.sharded_tensor.local_shards()[0].tensor.fill_(1)
      name_st = (
          ".sharded_tensor"
          if not _TORCH_GREATER_EQUAL_1_13
          else "sharded_tensor"
      )
      assert (
          name_st in m_0.state_dict()
      ), 'Expect "sharded_tensor" to appear in the state dict'
  
      m_1 = BoringModelWithShardedTensor(spec)
      assert not torch.allclose(
          m_1.sharded_tensor.local_shards()[0].tensor,
          m_0.sharded_tensor.local_shards()[0].tensor,
      ), "Expect the shards to be different before `m_1` loading `m_0`'s state dict"
  
      m_1.load_state_dict(m_0.state_dict(), strict=False)
      assert torch.allclose(
          m_1.sharded_tensor.local_shards()[0].tensor,
          m_0.sharded_tensor.local_shards()[0].tensor,
      ), "Expect the shards to be same after `m_1` loading `m_0`'s state dict"
  
imports: import sys
  import weakref
  from unittest.mock import Mock
  import pytest
  import torch
  from lightning.fabric import Fabric
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_1_13, _TORCH_GREATER_EQUAL_2_0
  from lightning.pytorch import LightningModule, Trainer
  from lightning.pytorch.core.module import _TrainerFabricShim
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.loggers import TensorBoardLogger
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from torch import nn
  from torch.optim import SGD, Adam
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 12 for calling a global function with example usage: test_sharded_tensor_state_dict(single_process_pg) without return types