code: def _sort_devices_by_perf(
      devices: List[List[DeviceHardware]],
  ) -> List[List[DeviceHardware]]:
      def _get_perf_sum(device_list: List[DeviceHardware]) -> float:
          perf = 0
          for device in device_list:
              perf += device.perf.total
          return perf
  
      return sorted(devices, key=_get_perf_sum)
  
imports: import copy
  import heapq
  import logging
  from dataclasses import dataclass
  from enum import Enum
  from typing import cast, Dict, List, Optional
  from torchrec.distributed.planner.perf_models import NoopPerfModel
  from torchrec.distributed.planner.types import DeviceHardware, PartitionByType, Partitioner, Perf, PerfModel, PlannerError, PlannerErrorType, ShardingOption, Storage, Topology
  from torchrec.distributed.planner.utils import bytes_to_gb, reset_shard_rank
  from torchrec.distributed.types import ShardingType
label_desc: Use image node_id 1 for calling a global function with example usage: _sort_devices_by_perf(devices) and returns: sorted, perf