code: def _rb_partition_balanced(weights, num_parts, eps):
      total_weight = weights[-1]
      lower = total_weight / num_parts  # best case heaviest partition
      upper = total_weight  # worst case heaviest partition
  
      # Do a binary search for the best partitioning
      while upper > lower + eps:
          mid = lower + ((upper - lower) / 2)
          parts, success = _lprobe(weights, num_parts, mid)
          if success:
              upper = mid
          else:
              lower = mid + eps
      return upper
  
imports: from collections.abc import Iterable
  from deepspeed.moe.utils import is_moe_param
  import os
  import psutil
  import gc
  from math import sqrt
  from math import floor
  from bisect import bisect_left
  import torch
  from torch import inf
  from deepspeed import comm
  from deepspeed.utils import groups, logger
  from deepspeed.runtime.constants import PIPE_REPLICATED
  from numpy import prod
label_desc: Use image node_id 17 for calling a global function with example usage: _rb_partition_balanced(weights, num_parts, eps) and returns: upper