class_docstr: Base class for table wise sharding.
class_docstr_tok: ["Base","class","for","table","wise","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:
          # pyre-fixme [16]
          shards = info.param_sharding.sharding_spec.shards
          # construct the global sharded_tensor_metadata
          global_metadata = ShardedTensorMetadata(
              shards_metadata=shards,
              size=torch.Size(
                  [
                      info.embedding_config.num_embeddings,
                      info.embedding_config.embedding_dim,
                  ]
              ),
          )
  
          # pyre-fixme [16]
          tables_per_rank[info.param_sharding.ranks[0]].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.embedding_config.num_embeddings,
                  local_cols=info.embedding_config.embedding_dim,
                  compute_kernel=EmbeddingComputeKernel(
                      info.param_sharding.compute_kernel
                  ),
                  local_metadata=shards[0],
                  global_metadata=global_metadata,
                  weight_init_max=info.embedding_config.weight_init_max,
                  weight_init_min=info.embedding_config.weight_init_min,
                  fused_params=info.fused_params,
                  pruning_indices_remapping=info.embedding_config.pruning_indices_remapping,
              )
          )
      return tables_per_rank
  
imports: from typing import Any, Callable, cast, Dict, List, Optional, TypeVar, Union
  import torch
  import torch.distributed
  from torchrec.distributed.dist_data import EmbeddingsAllToOne, KJTAllToAll, KJTOneToAll, PooledEmbeddingsAllToAll, VariableBatchPooledEmbeddingsAllToAll
  from torchrec.distributed.embedding_lookup import GroupedPooledEmbeddingsLookup, InferGroupedPooledEmbeddingsLookup
  from torchrec.distributed.embedding_sharding import BaseEmbeddingDist, BaseEmbeddingLookup, BaseSparseFeaturesDist, EmbeddingSharding, EmbeddingShardingContext, EmbeddingShardingInfo, group_tables
  from torchrec.distributed.embedding_types import BaseGroupedFeatureProcessor, EmbeddingComputeKernel, GroupedEmbeddingConfig, KJTList, ShardedEmbeddingTable
  from torchrec.distributed.types import Awaitable, CommOp, NullShardingContext, QuantizedCommCodecs, ShardedTensorMetadata, ShardingEnv, ShardMetadata
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
  from torchrec.streamable import Multistreamable
label_desc: Use image node_id 2 for calling the BaseTwEmbeddingSharding obj's underlying member method code with example usage: obj._shard(sharding_infos) and returns: tables_per_rank