code: def _freedman_diaconis_bins(a):
      """Calculate number of hist bins using Freedman-Diaconis rule."""
      # From https://stats.stackexchange.com/questions/798/
      a = np.asarray(a)
      if len(a) < 2:
          return 1
      iqr = np.subtract.reduce(np.nanpercentile(a, [75, 25]))
      h = 2 * iqr / (len(a) ** (1 / 3))
      # fall back to sqrt(a) bins if iqr is 0
      if h == 0:
          return int(np.sqrt(a.size))
      else:
          return int(np.ceil((a.max() - a.min()) / h))
  
imports: from numbers import Number
  from functools import partial
  import math
  import textwrap
  import warnings
  import numpy
  import pandas
  import matplotlib
  import matplotlib.pyplot
  import matplotlib.transforms
  from matplotlib.cbook import normalize_kwargs
  from matplotlib.colors import to_rgba
  from matplotlib.collections import LineCollection
  from ._base import VectorPlotter
  from ._statistics import ECDF, Histogram, KDE
  from ._stats.counting import Hist
  from .axisgrid import FacetGrid, _facet_docs
  from .utils import remove_na, _get_transform_functions, _kde_support, _check_argument, _assign_default_kwargs, _default_color
  from .palettes import color_palette
  from .external import husl
  from .external.kde import gaussian_kde
  from ._docstrings import DocstringComponents, _core_docs
label_desc: Use image node_id 6 for calling a global function with example usage: _freedman_diaconis_bins(a) and returns: int, int, int