code: def load_balance_peers(
      vector_size,
      bandwidths: Sequence[Optional[float]],
      min_size: int = 0,
  ) -> Tuple[int, ...]:
      """
      Find an optimal partitioning of weights for butterfly all-reduce given peer bandwidths.
      :param vector_size: total size of the averaged vector (in elements, not bytes)
      :param bandwidths: 1d array of non-negative bandwidths for each peer capable of averaging
        zeros stand for client-only participants, None represents "not specified" (resolved as mean of other pears)
      :param min_size: peers that can aggregate less than this many elements will be assigned nothing
      :returns: an integer array where i-th element is the number of weights assigned to i-th peer
      """
      specified_bandwidth = [
          item for item in bandwidths if item is not None and item > 0
      ]
  
      if specified_bandwidth:
          default_bandwidth = np.mean(specified_bandwidth)
          bandwidths = [
              item if item is not None else default_bandwidth
              for item in bandwidths
          ]
          scores = optimize_parts_lp(
              vector_size, np.asarray(bandwidths), min_size
          )
      else:
          assert not all(
              item == 0 for item in bandwidths
          ), "Must have at least one nonzero bandwidth"
          scores = np.asarray(
              [1.0 if item is None else 0.0 for item in bandwidths]
          )
  
      # TODO(jheuristic) we no longer need hagenbach-bishoff with new AllReduceRunner
      return tuple(hagenbach_bishoff(vector_size, scores))
  
imports: from typing import Optional, Sequence, Tuple
  import numpy
  import scipy.optimize
  from hivemind.utils.logging import get_logger
label_desc: Use image node_id 1 for calling a global function with example usage: load_balance_peers(vector_size, bandwidths, min_size) and returns: tuple