code: def randomly_distribute_N_balls_into_K_bins(
      N,  # int
      K,  # int
      *,
      max_balls_per_bin=None,
      min_balls_per_bin=None,
  ) -> np.ndarray:
      """Returns a uniformly random numpy integer array of length `N` that sums
      to `K`.
  
      Parameters
      ----------
      N : int
        Number of balls.
      K : int
        Number of bins.
      max_balls_per_bin : int
        Ensure that each bin contains at most `max_balls_per_bin` balls.
      min_balls_per_bin : int
        Ensure that each bin contains at least `min_balls_per_bin` balls.
  
      Returns
      -------
      int_array : np.array
        Length `N` array that sums to `K`.
      """
  
      if N == 0:
          return np.zeros(K, dtype=int)
      if max_balls_per_bin is None:
          max_balls_per_bin = N
      else:
          max_balls_per_bin = min(max_balls_per_bin, N)
      if min_balls_per_bin is None:
          min_balls_per_bin = 0
      else:
          min_balls_per_bin = min(min_balls_per_bin, N / K)
      if N / float(K) > max_balls_per_bin:
          N = max_balls_per_bin * K
  
      arr = np.round(
          generate_n_rand_probabilities_that_sum_to_m(
              n=K,
              m=1,
              max_prob=max_balls_per_bin / float(N),
              min_prob=min_balls_per_bin / float(N),
          )
          * N
      )
      while sum(arr) != N:
          while sum(arr) > N:  # pragma: no cover
              arr[np.argmax(arr)] -= 1
          while sum(arr) < N:
              arr[np.argmin(arr)] += 1
      return arr.astype(int)
  
file_path: cleanlab/cleanlab/benchmarking/noise_generation.py
imports: from typing import Optional
  import numpy
  from cleanlab.internal.util import value_counts
  from cleanlab.internal.constants import FLOATING_POINT_COMPARISON
label_desc: Use image node_id 5 for calling a global function with example usage: randomly_distribute_N_balls_into_K_bins(N, K) and returns: arr, np