code: def _binary_partition(weights: List, start: int, end: int):
      """Returns the binary partition position of `weights`, given the start
      position `st` and the end position `ed`.
  
      Args:
          weights (list): A python list to be binary partitioned
          start (int): the start position of the binary partition
          end (int): the end position of the binary partition
  
      Returns:
          int: the binary partition position of `weights`
      """
      w_sum = weights[end - 1]
      prefix = 0
      if start > 0:
          w_sum -= weights[start - 1]
          prefix = weights[start - 1]
      minimum = float("inf")
      for idx in range(start + 1, end):
          front = weights[idx - 1] - prefix
          diff = abs(w_sum - 2 * front)
          if diff < minimum:
              pos = idx
              minimum = diff
  
      return start, pos, end
  
file_path: ColossalAI/colossalai/legacy/pipeline/utils.py
imports: import heapq
  import inspect
  from collections import OrderedDict
  from typing import List
  import torch
  from colossalai.legacy.nn.layer.utils import CheckpointModule
  from colossalai.logging import get_dist_logger
label_desc: Use image node_id 1 for calling a global function with example usage: _binary_partition(weights, start, end) and returns: start,  pos,  end