class_docstr: Provides an optimized sharding plan for a given module with shardable parameters
  according to the provided sharders, topology, and constraints.
class_docstr_tok: ["Provides","an","optimized","sharding","plan","for","a","given","module","with","shardable","parameters","according","to","the","provided","sharders",",","topology",",","and","constraints","."]
code: def __init__(
      self,
      topology: Optional[Topology] = None,
      batch_size: Optional[int] = None,
      enumerator: Optional[Enumerator] = None,
      storage_reservation: Optional[StorageReservation] = None,
      proposer: Optional[Union[Proposer, List[Proposer]]] = None,
      partitioner: Optional[Partitioner] = None,
      performance_model: Optional[PerfModel] = None,
      stats: Optional[Union[Stats, List[Stats]]] = None,
      constraints: Optional[Dict[str, ParameterConstraints]] = None,
      debug: bool = True,
  ) -> None:
      if topology is None:
          topology = Topology(
              local_world_size=get_local_size(),
              world_size=dist.get_world_size(),
              compute_device="cuda"
              if torch.cuda.is_available()
              else "cpu",
          )
      self._topology: Topology = topology
      self._batch_size: int = batch_size if batch_size else BATCH_SIZE
      self._constraints = constraints
      self._enumerator: Enumerator = (
          enumerator
          if enumerator
          else EmbeddingEnumerator(
              topology=topology,
              batch_size=self._batch_size,
              constraints=constraints,
          )
      )
      self._storage_reservation: StorageReservation = (
          storage_reservation
          if storage_reservation
          else HeuristicalStorageReservation(percentage=0.15)
      )
      self._partitioner: Partitioner = (
          partitioner if partitioner else GreedyPerfPartitioner()
      )
      if proposer:
          self._proposers: List[Proposer] = (
              [proposer] if not isinstance(proposer, list) else proposer
          )
      else:
          self._proposers = [
              GridSearchProposer(),
              GreedyProposer(),
              GreedyProposer(use_depth=False),
              UniformProposer(),
          ]
      self._perf_model: PerfModel = (
          performance_model
          if performance_model
          else NoopPerfModel(topology=topology)
      )
  
      if stats is not None:
          self._stats: List[Stats] = (
              [stats] if not isinstance(stats, list) else stats
          )
      else:
          self._stats = [EmbeddingStats()]
  
      self._debug = debug
      self._num_proposals: int = 0
      self._num_plans: int = 0
      self._best_plan: Optional[List[ShardingOption]] = None
  
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 to create a new EmbeddingShardingPlanner object from inherited base classes: ShardingPlanner with example: obj = EmbeddingShardingPlanner(topology, batch_size, enumerator, storage_reservation, proposer, partitioner, performance_model, stats, constraints, debug)