code: def _to_sharding_plan(
      sharding_options: List[ShardingOption],
      topology: Topology,
  ) -> ShardingPlan:
      compute_device = topology.compute_device
      local_size = topology.local_world_size
  
      plan = {}
      for sharding_option in sharding_options:
          shards = sharding_option.shards
          sharding_type = sharding_option.sharding_type
  
          module_plan = plan.get(
              sharding_option.path, EmbeddingModuleShardingPlan()
          )
          module_plan[sharding_option.name] = ParameterSharding(
              sharding_spec=None
              if sharding_type == ShardingType.DATA_PARALLEL.value
              else EnumerableShardingSpec(
                  [
                      ShardMetadata(
                          shard_sizes=shard.size,
                          shard_offsets=shard.offset,
                          placement=placement(
                              compute_device,
                              cast(int, shard.rank),
                              local_size,
                          ),
                      )
                      for shard in shards
                  ]
              ),
              sharding_type=sharding_type,
              compute_kernel=sharding_option.compute_kernel,
              ranks=[cast(int, shard.rank) for shard in shards],
              cache_params=sharding_option.cache_params,
              enforce_hbm=sharding_option.enforce_hbm,
              stochastic_rounding=sharding_option.stochastic_rounding,
              bounds_check_mode=sharding_option.bounds_check_mode,
          )
          plan[sharding_option.path] = module_plan
      return ShardingPlan(plan)
  
imports: import copy
  from functools import reduce
  from time import perf_counter
  from typing import cast, Dict, List, Optional, Tuple, Union
  import torch
  import torch.distributed
  from torch import nn
  from torchrec.distributed.collective_utils import invoke_on_rank_and_broadcast_result
  from torchrec.distributed.comm import get_local_size
  from torchrec.distributed.planner.constants import BATCH_SIZE, MAX_SIZE
  from torchrec.distributed.planner.enumerators import EmbeddingEnumerator
  from torchrec.distributed.planner.partitioners import GreedyPerfPartitioner
  from torchrec.distributed.planner.perf_models import NoopPerfModel
  from torchrec.distributed.planner.proposers import GreedyProposer, GridSearchProposer, UniformProposer
  from torchrec.distributed.planner.stats import EmbeddingStats
  from torchrec.distributed.planner.storage_reservations import HeuristicalStorageReservation
  from torchrec.distributed.planner.types import Enumerator, ParameterConstraints, Partitioner, PerfModel, PlannerError, PlannerErrorType, Proposer, ShardingOption, Stats, Storage, StorageReservation, Topology
  from torchrec.distributed.planner.utils import bytes_to_gb, reset_shard_rank, storage_repr_in_gb
  from torchrec.distributed.sharding_plan import get_default_sharders, placement
  from torchrec.distributed.types import EmbeddingModuleShardingPlan, EnumerableShardingSpec, ModuleSharder, ParameterSharding, ShardingPlan, ShardingPlanner, ShardingType, ShardMetadata
label_desc: Use image node_id 1 for calling a global function with example usage: _to_sharding_plan(sharding_options, topology) and returns: ShardingPlan