class_docstr: Redistributes pooled embedding tensor in TWRW fashion by performing a reduce-scatter
  operation row wise on the host level and then an AlltoAll operation table wise on
  the global level.
  
  Args:
      cross_pg (dist.ProcessGroup): global level ProcessGroup for AlltoAll
          communication.
      intra_pg (dist.ProcessGroup): host level ProcessGroup for reduce-scatter
          communication.
      dim_sum_per_node (List[int]): number of features (sum of dimensions) of the
          embedding for each host.
      emb_dim_per_node_per_feature (List[List[int]]):
      device (Optional[torch.device]): device on which buffers will be allocated.
      qcomm_codecs_registry (Optional[Dict[str, QuantizedCommCodecs]]):
class_docstr_tok: ["Redistributes","pooled","embedding","tensor","in","TWRW","fashion","by","performing","a","reduce-scatter","operation","row","wise","on","the","host","level","and","then","an","AlltoAll","operation","table","wise","on","the","global","level",".","Args",":","cross_pg","(","dist.ProcessGroup",")",":","global","level","ProcessGroup","for","AlltoAll","communication",".","intra_pg","(","dist.ProcessGroup",")",":","host","level","ProcessGroup","for","reduce-scatter","communication",".","dim_sum_per_node","(","List","[","int","]",")",":","number","of","features","(","sum","of","dimensions",")","of","the","embedding","for","each","host",".","emb_dim_per_node_per_feature","(","List","[","List","[","int","]","]",")",":","device","(","Optional","[","torch.device","]",")",":","device","on","which","buffers","will","be","allocated",".","qcomm_codecs_registry","(","Optional","[","Dict","[","str",",","QuantizedCommCodecs","]","]",")",":"]
code: def _create_output_dist_modules(
      self, sharding_ctx: Optional[EmbeddingShardingContext] = None
  ) -> None:
      if (
          sharding_ctx is not None
          and sharding_ctx.variable_batch_per_feature
      ):
          self._intra_dist = VariableBatchPooledEmbeddingsReduceScatter(
              pg=self._intra_pg,
              codecs=self._intra_codecs,
          )
          self._cross_dist = VariableBatchPooledEmbeddingsAllToAll(
              pg=self._cross_pg,
              emb_dim_per_rank_per_feature=self._emb_dim_per_node_per_feature,
              device=self._device,
              callbacks=None,  # don't pass permute callback, handle in LazyAwaitable
              codecs=self._cross_codecs,
          )
      else:
          self._intra_dist = PooledEmbeddingsReduceScatter(
              pg=self._intra_pg,
              codecs=self._intra_codecs,
          )
          self._cross_dist = PooledEmbeddingsAllToAll(
              pg=self._cross_pg,
              dim_sum_per_rank=self._dim_sum_per_node,
              device=self._device,
              codecs=self._cross_codecs,
          )
  
imports: import itertools
  import math
  from typing import Any, cast, Dict, List, Optional, Tuple, TypeVar, Union
  import torch
  import torch.distributed
  from torchrec.distributed.comm import get_local_size, intra_and_cross_node_pg
  from torchrec.distributed.dist_data import KJTAllToAll, PooledEmbeddingsAllToAll, PooledEmbeddingsReduceScatter, VariableBatchPooledEmbeddingsAllToAll, VariableBatchPooledEmbeddingsReduceScatter
  from torchrec.distributed.embedding_lookup import GroupedPooledEmbeddingsLookup
  from torchrec.distributed.embedding_sharding import BaseEmbeddingDist, BaseEmbeddingLookup, BaseSparseFeaturesDist, bucketize_kjt_before_all2all, EmbeddingSharding, EmbeddingShardingContext, EmbeddingShardingInfo, group_tables
  from torchrec.distributed.embedding_types import BaseGroupedFeatureProcessor, EmbeddingComputeKernel, GroupedEmbeddingConfig, ShardedEmbeddingTable
  from torchrec.distributed.types import Awaitable, CommOp, QuantizedCommCodecs, ShardedTensorMetadata, ShardingEnv, ShardMetadata
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
  from torchrec.streamable import Multistreamable
label_desc: Use image node_id 5 for calling the TwRwPooledEmbeddingDist obj's underlying member method code with example usage: obj._create_output_dist_modules(sharding_ctx) without return types