code: def partition_balanced(weights, num_parts, eps=1e-3):
      num_items = len(weights)
      # First check for the trivial edge case
      if num_items <= num_parts:
          return partition_uniform(num_items, num_parts)
  
      weights_ = prefix_sum_inc(weights)
  
      # Find the smallest bottleneck (weight of heaviest partition)
      bottleneck = _rb_partition_balanced(weights_, num_parts, eps=eps)
  
      # Now compute that partitioning
      parts, success = _lprobe(weights_, num_parts, bottleneck)
      assert success
  
      return parts
  
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 18 for calling a global function with example usage: partition_balanced(weights, num_parts, eps) and returns: parts, partition_uniform