code: def _get_tower_index(
      name: str, child_module: EmbeddingTowerCollection
  ) -> int:
      for i, tower in enumerate(child_module.towers):
          for n, m in tower.named_modules():
              if isinstance(m, nn.Embedding) or isinstance(
                  m, nn.EmbeddingBag
              ):
                  table_name = n.split(".")[-1]
                  if name == table_name:
                      return i
      raise RuntimeError(
          f"couldn't get the tower index for table {name}, tower collection: {child_module}"
      )
  
imports: import logging
  from typing import Dict, List, Optional, Tuple, Union
  from torch import nn
  from torchrec.distributed.embedding_types import EmbeddingComputeKernel
  from torchrec.distributed.planner.constants import POOLING_FACTOR
  from torchrec.distributed.planner.shard_estimators import EmbeddingPerfEstimator, EmbeddingStorageEstimator
  from torchrec.distributed.planner.types import Enumerator, ParameterConstraints, PartitionByType, Shard, ShardEstimator, ShardingOption, Topology
  from torchrec.distributed.planner.utils import sharder_name
  from torchrec.distributed.sharding_plan import calculate_shard_sizes_and_offsets
  from torchrec.distributed.types import BoundsCheckMode, CacheParams, ModuleSharder, ShardingType
  from torchrec.modules.embedding_tower import EmbeddingTower, EmbeddingTowerCollection
label_desc: Use image node_id 3 for calling a global function with example usage: _get_tower_index(name, child_module) and returns: i