code: def _get_parameter_sharding(
      param: nn.Parameter,
      sharding_type: str,
      size_offset_ranks: List[Tuple[List[int], List[int], int]],
      local_size: int,
      device_type: str,
      sharder: ModuleSharder[nn.Module],
      placements: Optional[List[str]] = None,
      compute_kernel: Optional[str] = None,
  ) -> ParameterSharding:
      return ParameterSharding(
          sharding_spec=None
          if sharding_type == ShardingType.DATA_PARALLEL.value
          else EnumerableShardingSpec(
              [
                  ShardMetadata(
                      shard_sizes=size,
                      shard_offsets=offset,
                      placement=placement(
                          device_type,
                          none_throws(rank),
                          none_throws(local_size),
                      )
                      if not device_placement
                      else device_placement,
                  )
                  for (size, offset, rank), device_placement in zip(
                      size_offset_ranks,
                      placements
                      if placements
                      else [None] * len(size_offset_ranks),
                  )
              ]
          ),
          sharding_type=sharding_type,
          compute_kernel=compute_kernel
          if compute_kernel
          else _get_compute_kernel(
              sharder, param, sharding_type, device_type
          ),
          ranks=[rank for (_, _, rank) in size_offset_ranks],
      )
  
imports: import math
  import warnings
  from typing import Callable, cast, Dict, List, Optional, Tuple, Type
  import torch
  from torch import distributed, nn
  from torchrec.distributed.comm import get_local_size
  from torchrec.distributed.embedding import EmbeddingCollectionSharder
  from torchrec.distributed.embedding_types import EmbeddingComputeKernel
  from torchrec.distributed.embeddingbag import EmbeddingBagCollectionSharder
  from torchrec.distributed.fp_embeddingbag import FeatureProcessedEmbeddingBagCollectionSharder
  from torchrec.distributed.fused_embeddingbag import FusedEmbeddingBagCollectionSharder
  from torchrec.distributed.mc_embedding import ManagedCollisionEmbeddingCollectionSharder
  from torchrec.distributed.mc_embeddingbag import ManagedCollisionEmbeddingBagCollectionSharder
  from torchrec.distributed.planner.constants import MIN_CW_DIM
  from torchrec.distributed.quant_embedding import QuantEmbeddingCollectionSharder
  from torchrec.distributed.quant_embeddingbag import QuantEmbeddingBagCollectionSharder
  from torchrec.distributed.types import EmbeddingModuleShardingPlan, EnumerableShardingSpec, ModuleSharder, ParameterSharding, ShardingType, ShardMetadata
  from torchrec.distributed.utils import none_throws
label_desc: Use image node_id 10 for calling a global function with example usage: _get_parameter_sharding(param, sharding_type, size_offset_ranks, local_size, device_type, sharder, placements, compute_kernel) and returns: ParameterSharding