code: def _collapse_consecutive_ranks(ranks: List[int]) -> List[str]:
      if len(ranks) > 1 and ranks == list(
          range(min(ranks), max(ranks) + 1)
      ):
          return [f"{min(ranks)}-{max(ranks)}"]
      else:
          return [str(rank) for rank in ranks]
  
imports: import logging
  from collections import defaultdict
  from typing import Any, cast, Dict, List, Optional, Tuple, Union
  from torch import nn
  from torchrec.distributed.planner.constants import BIGINT_DTYPE, NUM_POOLINGS
  from torchrec.distributed.planner.shard_estimators import _calculate_shard_io_sizes
  from torchrec.distributed.planner.storage_reservations import FixedPercentageStorageReservation, HeuristicalStorageReservation, InferenceStorageReservation
  from torchrec.distributed.planner.types import ParameterConstraints, Perf, ShardingOption, Stats, Storage, StorageReservation, Topology
  from torchrec.distributed.planner.utils import _find_imbalance_tables, bytes_to_gb, bytes_to_mb, sharder_name
  from torchrec.distributed.types import ModuleSharder, ParameterSharding, ShardingPlan, ShardingType
label_desc: Use image node_id 8 for calling a global function with example usage: _collapse_consecutive_ranks(ranks) and returns: list, unknown