code: def cat_hist(val, rug, side, shade, ax, **shade_kwargs):
      """Auxiliary function to plot discrete-violinplots."""
      bins = get_bins(val)
      _, binned_d, _ = histogram(val, bins=bins)
  
      bin_edges = np.linspace(np.min(val), np.max(val), len(bins))
      heights = np.diff(bin_edges)
      centers = bin_edges[:-1] + heights.mean() / 2
  
      if rug and side == "both":
          side = "right"
  
      if side == "right":
          left = None
      elif side == "left":
          left = -binned_d
      elif side == "both":
          left = -0.5 * binned_d
  
      ax.barh(
          centers,
          binned_d,
          height=heights,
          left=left,
          alpha=shade,
          **shade_kwargs,
      )
      return binned_d
  
file_path: arviz/arviz/plots/backends/matplotlib/violinplot.py
imports: import matplotlib.pyplot
  import numpy
  from ....stats import hdi
  from ....stats.density_utils import get_bins, histogram, kde
  from ...plot_utils import _scale_fig_size
  from .None import backend_kwarg_defaults, backend_show, create_axes_grid, matplotlib_kwarg_dealiaser
label_desc: Use image node_id 3 for calling a global function with example usage: cat_hist(val, rug, side, shade, ax) and returns: binned_d