code: def _adjust_small_clusters(array, n_clusters):
      """Take a ndarray of floats summing to n_clusters \
      and try to round it while enforcing rounded array still sum \
      to n_clusters and every element is at least 1."""
      array_round = np.rint(array).astype(int)
      array_round = np.maximum(array_round, 1)
  
      if np.sum(array_round) < n_clusters:
          while np.sum(array_round) != n_clusters:
              idx = np.argmax(array - array_round)
              array_round[idx] += 1
      elif np.sum(array_round) == n_clusters:
          pass
      elif np.sum(array_round) > n_clusters:
          parent_idx_ = np.arange(array_round.shape[0])
          while np.sum(array_round) != n_clusters:
              # prevent element rounded to 1 to be decreased in edge cases
              mask = array_round != 1
              idx = np.argmin(array[mask] - array_round[mask])
              parent_idx = parent_idx_[mask][idx]
              array_round[parent_idx] -= 1
      return array_round
  
file_path: nilearn/nilearn/regions/hierarchical_kmeans_clustering.py
imports: import warnings
  import numpy
  from sklearn.base import BaseEstimator, ClusterMixin, TransformerMixin
  from sklearn.cluster import MiniBatchKMeans
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 2 for calling a global function with example usage: _adjust_small_clusters(array, n_clusters) and returns: array_round