code: def check_optimality(vector_size, bandwidths, ref_partitions):
      partitions = list(load_balance_peers(vector_size, bandwidths))
      assert get_cost(vector_size, partitions, bandwidths) <= get_cost(
          vector_size, ref_partitions, bandwidths
      )
  
imports: import random
  import time
  import numpy
  import pytest
  import torch
  import hivemind
  from hivemind.averaging import DecentralizedAverager
  from hivemind.averaging.allreduce import AveragingMode
  from hivemind.averaging.control import AveragingStage
  from hivemind.averaging.key_manager import GroupKeyManager
  from hivemind.averaging.load_balancing import load_balance_peers
  from hivemind.averaging.partition import AllreduceException
  from hivemind.p2p import PeerID
  from test_utils.dht_swarms import launch_dht_instances
label_desc: Use image node_id 9 for calling a global function with example usage: check_optimality(vector_size, bandwidths, ref_partitions) without return types