code: def clip_values(x, low=0.0, high=1.0, new_sum=None) -> np.ndarray:
      """Clip all values in p to range [low,high].
      Preserves sum of x.
  
      Parameters
      ----------
      x : np.ndarray
          An array / list of values to be clipped.
  
      low : float
          values in x greater than 'low' are clipped to this value
  
      high : float
          values in x greater than 'high' are clipped to this value
  
      new_sum : float
          normalizes x after clipping to sum to new_sum
  
      Returns
      -------
      x : np.ndarray
          A list of clipped values, summing to the same sum as x."""
  
      def clip_range(a, low=low, high=high):
          """Clip a into range [low,high]"""
          return min(max(a, low), high)
  
      vectorized_clip = np.vectorize(
          clip_range
      )  # Vectorize clip_range for efficiency with np.ndarrays
      prev_sum = (
          sum(x) if new_sum is None else new_sum
      )  # Store previous sum
      x = vectorized_clip(x)  # Clip all values (efficiently)
      x = (
          x
          * prev_sum
          / np.clip(float(sum(x)), a_min=TINY_VALUE, a_max=None)
      )  # Re-normalized values to sum to previous sum
      return x
  
imports: import warnings
  import numpy
  import pandas
  from typing import Union, Tuple
  from cleanlab.typing import DatasetLike, LabelLike
  from cleanlab.internal.validation import labels_to_array
  from cleanlab.internal.constants import FLOATING_POINT_COMPARISON, TINY_VALUE
label_desc: Use image node_id 3 for calling a global function with example usage: clip_values(x, low, high, new_sum) and returns: x, min