@classmethod
def _init_from_local_shards(cls, local_shards: List[Shard], *global_size, process_group=None, init_rrefs=False):
    process_group = (process_group if (process_group is not None) else distributed_c10d._get_default_group())
    current_rank = dist.get_rank(process_group)
    world_size = dist.get_world_size(process_group)
    local_sharded_tensor_metadata: Optional[ShardedTensorMetadata] = None
    global_tensor_size = _flatten_tensor_size(global_size)
    if (len(local_shards) > 0):
        local_sharded_tensor_metadata = build_metadata_from_local_shards(local_shards, global_tensor_size, current_rank, process_group)
    gathered_metadatas: List[Optional[ShardedTensorMetadata]] = []
    if (world_size > 1):
        gathered_metadatas = [None for _ in range(world_size)]
        dist.all_gather_object(gathered_metadatas, local_sharded_tensor_metadata, group=process_group)
    else:
        gathered_metadatas = [local_sharded_tensor_metadata]
    global_sharded_tensor_metadata = build_global_metadata(gathered_metadatas)
    sharded_tensor = cls.__new__(cls)
    sharded_tensor._prepare_init(process_group=process_group, init_rrefs=init_rrefs)
    sharded_tensor._metadata = global_sharded_tensor_metadata
    sharded_tensor._local_shards = local_shards
    sharded_tensor._sharding_spec = EnumerableShardingSpec(global_sharded_tensor_metadata.shards_metadata)
    sharded_tensor._post_init()
    return sharded_tensor
@classmethod
def _init_from_local_shards(cls, local_shards: List[Shard], *global_size, process_group=None, init_rrefs=False):
    process_group = (process_group if (process_group is not None) else distributed_c10d._get_default_group())
    current_rank = dist.get_rank(process_group)
    world_size = dist.get_world_size(process_group)
    local_sharded_tensor_metadata: Optional[ShardedTensorMetadata] = None
    global_tensor_size = _flatten_tensor_size(global_size)
    if (len(local_shards) > 0):
        local_sharded_tensor_metadata = build_metadata_from_local_shards(local_shards, global_tensor_size, current_rank, process_group)
    gathered_metadatas: List[Optional[ShardedTensorMetadata]] = []
    if (world_size > 1):
        gathered_metadatas = [None for _ in range(world_size)]
        dist.all_gather_object(gathered_metadatas, local_sharded_tensor_metadata, group=process_group)
    else:
        gathered_metadatas = [local_sharded_tensor_metadata]
    global_sharded_tensor_metadata = build_global_metadata(gathered_metadatas)
    sharded_tensor = cls.__new__(cls)
    sharded_tensor._prepare_init(process_group=process_group, init_rrefs=init_rrefs)
    sharded_tensor._metadata = global_sharded_tensor_metadata
    sharded_tensor._local_shards = local_shards
    sharded_tensor._sharding_spec = EnumerableShardingSpec(global_sharded_tensor_metadata.shards_metadata)
    sharded_tensor._post_init()
    return sharded_tensor