code: def _trim_crange(values, nan_mask):
      """Trim the color range, but prevent the color range from collapsing."""
      # Get vmin and vmax as 5. and 95. percentiles
      vmin = np.nanpercentile(values, 5)
      vmax = np.nanpercentile(values, 95)
      if (
          vmin == vmax
      ):  # if percentile range is equal, take 1./99. perc.
          vmin = np.nanpercentile(values, 1)
          vmax = np.nanpercentile(values, 99)
          if vmin == vmax:  # if still equal, use min/max
              vmin = np.min(values)
              vmax = np.max(values)
  
      if vmin > vmax:  # fixes rare numerical precision issues
          vmin = vmax
  
      # Get color values depending on value range
      cvals = values[np.invert(nan_mask)].astype(np.float64)
      cvals_imp = cvals.copy()
      cvals_imp[np.isnan(cvals)] = (vmin + vmax) / 2.0
      cvals[cvals_imp > vmax] = vmax
      cvals[cvals_imp < vmin] = vmin
  
      return vmin, vmax, cvals
  
file_path: shap/shap/plots/_violin.py
imports: import warnings
  import matplotlib.pyplot
  import numpy
  import pandas
  from scipy.stats import gaussian_kde
  from ..utils._exceptions import DimensionError
  from .None import colors
  from ._labels import labels
label_desc: Use image node_id 2 for calling a global function with example usage: _trim_crange(values, nan_mask) and returns: vmin,  vmax,  cvals