code: def _create_managed_collision_modules(
      self, module: ManagedCollisionCollection
  ) -> None:
      self._mc_module_name_shard_metadata: DefaultDict[
          str, DefaultDict[str, List[int]]
      ] = defaultdict(lambda: defaultdict(list))
      self._feature_to_offset: Dict[str, int] = {}
  
      for (
          sharding_type,
          sharding,
      ) in self._sharding_type_to_sharding.items():
          if sharding_type == ShardingType.ROW_WISE.value:
              assert isinstance(sharding, BaseRwEmbeddingSharding)
  
              grouped_embedding_configs: List[
                  GroupedEmbeddingConfig
              ] = sharding._grouped_embedding_configs
              for group_config in grouped_embedding_configs:
                  for table in group_config.embedding_tables:
                      # pyre-ignore [16]
                      new_min_output_id = (
                          table.local_metadata.shard_offsets[0]
                      )
                      # pyre-ignore [16]
                      new_range_size = table.local_metadata.shard_sizes[
                          0
                      ]
  
                      mc_module = module._managed_collision_modules[
                          table.name
                      ]
  
                      # TODO:
                      #  1) need to make TBE accept global indices for now force to local indices
                      #  2) MCH is particularly nasty with a portion of each shard; ideally dont do this
                      #  3) now create a feature_to_offset and pass into awaitable callbacks to act as raw id adder
                      self._managed_collision_modules[
                          table.name
                      ] = mc_module.rebuild_with_output_id_range(
                          output_id_range=(
                              0,  # new_min_output_id,
                              new_range_size,  # new_min_output_id + new_range_size,
                          ),
                          device=self._device,
                      )
                      zch_size = self._managed_collision_modules[
                          table.name
                      ]._zch_size
  
                      zch_size_by_rank = [
                          torch.zeros(
                              1, dtype=torch.int64, device=self._device
                          )
                          for _ in range(self._env.world_size)
                      ]
                      if self._env.world_size > 1:
                          dist.all_gather(
                              zch_size_by_rank,
                              torch.tensor(
                                  [zch_size],
                                  dtype=torch.int64,
                                  device=self._device,
                              ),
                              group=self._env.process_group,
                          )
                      else:
                          zch_size_by_rank[0] = torch.tensor(
                              [zch_size],
                              dtype=torch.int64,
                              device=self._device,
                          )
  
                      # Calculate the sum of all ZCH sizes from rank 0 to list
                      # index. The last item is the sum of all elements in zch_size_by_rank
                      zch_size_cumsum = torch.cumsum(
                          torch.cat(zch_size_by_rank), dim=0
                      ).tolist()
  
                      zch_size_sum_before_this_rank = (
                          zch_size_cumsum[self._env.rank] - zch_size
                      )
  
                      self._mc_module_name_shard_metadata[
                          table.name
                      ] = (
                          zch_size_sum_before_this_rank,
                          zch_size,
                          zch_size_cumsum[-1],
                      )
                      for feature in table.feature_names:
                          self._feature_to_offset[
                              feature
                          ] = new_min_output_id
  
imports: import copy
  from collections import defaultdict, OrderedDict
  from dataclasses import dataclass
  from typing import Any, DefaultDict, Dict, Iterator, List, Optional, Type
  import torch
  import torch.distributed
  from torch import nn
  from torch.distributed._shard.sharded_tensor import Shard
  from torchrec.distributed.comm import get_local_rank
  from torchrec.distributed.embedding import _construct_jagged_tensors, EmbeddingCollectionContext
  from torchrec.distributed.embedding_sharding import EmbeddingSharding, EmbeddingShardingContext, EmbeddingShardingInfo, KJTListSplitsAwaitable
  from torchrec.distributed.embedding_types import BaseEmbeddingSharder, GroupedEmbeddingConfig, KJTList
  from torchrec.distributed.sharding.rw_sequence_sharding import RwSequenceEmbeddingDist, RwSequenceEmbeddingSharding
  from torchrec.distributed.sharding.rw_sharding import BaseRwEmbeddingSharding, RwSparseFeaturesDist
  from torchrec.distributed.sharding.sequence_sharding import SequenceShardingContext
  from torchrec.distributed.types import Awaitable, LazyAwaitable, ParameterSharding, QuantizedCommCodecs, ShardedModule, ShardedTensor, ShardingEnv, ShardingType, ShardMetadata
  from torchrec.distributed.utils import append_prefix
  from torchrec.modules.mc_modules import apply_mc_method_to_jt_dict, ManagedCollisionCollection
  from torchrec.sparse.jagged_tensor import JaggedTensor, KeyedJaggedTensor
label_desc: Use image node_id 3 for calling the ShardedManagedCollisionCollection obj's underlying member method code with example usage: obj._create_managed_collision_modules(module) without return types