class_docstr: Base class for data-parallel sharding.
class_docstr_tok: ["Base","class","for","data-parallel","sharding","."]
code: def _shard(
      self,
      sharding_infos: List[EmbeddingShardingInfo],
  ) -> List[List[ShardedEmbeddingTable]]:
      world_size = self._world_size
      tables_per_rank: List[List[ShardedEmbeddingTable]] = [
          [] for i in range(world_size)
      ]
      for info in sharding_infos:
          for rank in range(world_size):
              tables_per_rank[rank].append(
                  ShardedEmbeddingTable(
                      num_embeddings=info.embedding_config.num_embeddings,
                      embedding_dim=info.embedding_config.embedding_dim,
                      name=info.embedding_config.name,
                      embedding_names=info.embedding_config.embedding_names,
                      data_type=info.embedding_config.data_type,
                      feature_names=info.embedding_config.feature_names,
                      pooling=info.embedding_config.pooling,
                      is_weighted=info.embedding_config.is_weighted,
                      has_feature_processor=info.embedding_config.has_feature_processor,
                      local_rows=info.param.size(0),
                      local_cols=info.param.size(1),
                      compute_kernel=EmbeddingComputeKernel(
                          info.param_sharding.compute_kernel
                      ),
                      local_metadata=None,
                      global_metadata=None,
                      weight_init_max=info.embedding_config.weight_init_max,
                      weight_init_min=info.embedding_config.weight_init_min,
                      fused_params=info.fused_params,
                  )
              )
      return tables_per_rank
  
imports: from typing import Any, cast, Dict, List, Optional, TypeVar
  import torch
  from torchrec.distributed.embedding_lookup import GroupedPooledEmbeddingsLookup
  from torchrec.distributed.embedding_sharding import BaseEmbeddingDist, BaseEmbeddingLookup, BaseSparseFeaturesDist, EmbeddingSharding, EmbeddingShardingContext, EmbeddingShardingInfo, group_tables
  from torchrec.distributed.embedding_types import BaseGroupedFeatureProcessor, EmbeddingComputeKernel, GroupedEmbeddingConfig, ShardedEmbeddingTable
  from torchrec.distributed.types import Awaitable, NoWait, ShardingEnv, ShardMetadata
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
  from torchrec.streamable import Multistreamable
label_desc: Use image node_id 2 for calling the BaseDpEmbeddingSharding obj's underlying member method code with example usage: obj._shard(sharding_infos) and returns: tables_per_rank