code: def row_wise(
      sizes_placement: Optional[Tuple[List[int], str]] = None
  ) -> ParameterShardingGenerator:
      """
      Returns a generator of ParameterShardingPlan for `ShardingType::ROW_WISE` for construct_module_sharding_plan.
  
      Args:
      sizes_placement (Optional[Tuple[List[int], str]]): Only use it in inference for uneven shardinglist of tuples of (sizes, placement); sizes is the row size list
  
      Example::
  
          ebc = EmbeddingBagCollection(...)
          plan = construct_module_sharding_plan(
              ebc,
              {
                  "table_1": row_wise(),
                  "table_2": row_wise([10, 5, 0, 3], "cpu")
              },
          )
      """
  
      def _parameter_sharding_generator(
          param: nn.Parameter,
          local_size: int,
          world_size: int,
          device_type: str,
          sharder: ModuleSharder[nn.Module],
      ) -> ParameterSharding:
          if sizes_placement is None:
              size_and_offsets = _get_parameter_size_offsets(
                  param,
                  ShardingType.ROW_WISE,
                  local_size,
                  world_size,
              )
              assert len(size_and_offsets) <= world_size
              size_offset_ranks = []
              for (size, offset), rank in zip(
                  size_and_offsets, range(world_size)
              ):
                  size_offset_ranks.append((size, offset, rank))
          else:
              size_offset_ranks = []
              sizes = sizes_placement[0]
              (rows, cols) = param.shape
              cur_offset = 0
              prev_offset = 0
              for rank, size in enumerate(sizes):
                  per_rank_row = size
                  cur_offset += per_rank_row
                  cur_offset = min(cur_offset, rows)
                  per_rank_row = cur_offset - prev_offset
                  size_offset_ranks.append(
                      ([per_rank_row, cols], [prev_offset, 0], rank)
                  )
                  prev_offset = cur_offset
  
              if cur_offset < rows:
                  raise ValueError(
                      f"Cannot fit tensor of {rows, cols} into sizes_ranks_placements = {sizes_placement}"
                  )
  
          def placement_helper(device_type: str, index: int = 0) -> str:
              if device_type == "cpu":
                  return f"rank:0/{device_type}"  # cpu only use rank 0
  
              return f"rank:{index}/{device_type}:{index}"
  
          return _get_parameter_sharding(
              param,
              ShardingType.ROW_WISE.value,
              size_offset_ranks,
              local_size,
              device_type,
              sharder,
              placements=[
                  placement_helper(sizes_placement[1], i)
                  for i in range(len(sizes_placement[0]))
              ]
              if sizes_placement
              else None,
              compute_kernel=EmbeddingComputeKernel.QUANT.value
              if sizes_placement
              else None,
          )
  
      return _parameter_sharding_generator
  
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 13 for calling a global function with example usage: row_wise(sizes_placement) and returns: _parameter_sharding_generator, _get_parameter_sharding, str, index, str, device_type, str, index, str, device_type