code: def data_parallel() -> ParameterShardingGenerator:
      """
      Returns a generator of ParameterShardingPlan for `ShardingType::DATA_PARALLEL` for construct_module_sharding_plan.
  
      Example::
  
          ebc = EmbeddingBagCollection(...)
          plan = construct_module_sharding_plan(
              ebc,
              {
                  "table_0": data_parallel(),
              },
          )
      """
  
      def _parameter_sharding_generator(
          param: nn.Parameter,
          local_size: int,
          world_size: int,
          device_type: str,
          sharder: ModuleSharder[nn.Module],
      ) -> ParameterSharding:
          size_and_offsets = _get_parameter_size_offsets(
              param,
              ShardingType.DATA_PARALLEL,
              local_size,
              world_size,
          )
          size_offset_ranks = []
  
          assert len(size_and_offsets) == world_size
          for (size, offset), rank in zip(
              size_and_offsets, range(world_size)
          ):
              size_offset_ranks.append((size, offset, rank))
  
          return _get_parameter_sharding(
              param,
              ShardingType.DATA_PARALLEL.value,
              size_offset_ranks,
              local_size,
              device_type,
              sharder,
          )
  
      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 11 for calling a global function with example usage: data_parallel() and returns: _parameter_sharding_generator, _get_parameter_sharding