code: def kde(x, circular=False, **kwargs):
      """One dimensional density estimation.
  
      It is a wrapper around ``kde_linear()`` and ``kde_circular()``.
  
      Parameters
      ----------
      x : 1D numpy array
          Data used to calculate the density estimation.
      circular : bool, optional
          Whether ``x`` is a circular variable or not. Defaults to False.
      kwargs : dict, optional
          Arguments passed to ``kde_linear()`` and ``kde_circular()``.
          See their documentation for more info.
  
      Returns
      -------
      grid : numpy.ndarray
          Gridded numpy array for the x values.
      pdf : numpy.ndarray
          Numpy array for the density estimates.
      bw : float
          The estimated bandwidth. Only returned if requested.
  
      Examples
      --------
      Default density estimation for linear data
  
      .. plot::
          :context: close-figs
  
          >>> import numpy as np
          >>> import matplotlib.pyplot as plt
          >>> from arviz import kde
          >>>
          >>> rng = np.random.default_rng(49)
          >>> rvs = rng.gamma(shape=1.8, size=1000)
          >>> grid, pdf = kde(rvs)
          >>> plt.plot(grid, pdf)
  
      Density estimation for linear data with Silverman's rule bandwidth
  
      .. plot::
          :context: close-figs
  
          >>> grid, pdf = kde(rvs, bw="silverman")
          >>> plt.plot(grid, pdf)
  
      Density estimation for linear data with scaled bandwidth
  
      .. plot::
          :context: close-figs
  
          >>> # bw_fct > 1 means more smoothness.
          >>> grid, pdf = kde(rvs, bw_fct=2.5)
          >>> plt.plot(grid, pdf)
  
      Default density estimation for linear data with extended limits
  
      .. plot::
          :context: close-figs
  
          >>> grid, pdf = kde(rvs, bound_correction=False, extend=True, extend_fct=0.5)
          >>> plt.plot(grid, pdf)
  
      Default density estimation for linear data with custom limits
  
      .. plot::
          :context: close-figs
  
          >>> # It accepts tuples and lists of length 2.
          >>> grid, pdf = kde(rvs, bound_correction=False, custom_lims=(0, 11))
          >>> plt.plot(grid, pdf)
  
      Default density estimation for circular data
  
      .. plot::
          :context: close-figs
  
          >>> rvs = np.random.vonmises(mu=np.pi, kappa=1, size=500)
          >>> grid, pdf = kde(rvs, circular=True)
          >>> plt.plot(grid, pdf)
  
      Density estimation for circular data with scaled bandwidth
  
      .. plot::
          :context: close-figs
  
          >>> rvs = np.random.vonmises(mu=np.pi, kappa=1, size=500)
          >>> # bw_fct > 1 means less smoothness.
          >>> grid, pdf = kde(rvs, circular=True, bw_fct=3)
          >>> plt.plot(grid, pdf)
  
      Density estimation for circular data with custom limits
  
      .. plot::
          :context: close-figs
  
          >>> # This is still experimental, does not always work.
          >>> rvs = np.random.vonmises(mu=0, kappa=30, size=500)
          >>> grid, pdf = kde(rvs, circular=True, custom_lims=(-1, 1))
          >>> plt.plot(grid, pdf)
  
      See Also
      --------
      plot_kde : Compute and plot a kernel density estimate.
      """
      x = x[np.isfinite(x)]
      if x.size == 0 or np.all(x == x[0]):
          warnings.warn(
              "Your data appears to have a single value or no finite values"
          )
  
          return np.zeros(2), np.array([np.nan] * 2)
  
      if circular:
          if circular == "degrees":
              x = np.radians(x)
          kde_fun = _kde_circular
      else:
          kde_fun = _kde_linear
  
      return kde_fun(x, **kwargs)
  
imports: import warnings
  import numpy
  from scipy.fftpack import fft
  from scipy.optimize import brentq
  from scipy.signal import convolve, convolve2d, gaussian
  from scipy.sparse import coo_matrix
  from scipy.special import ive
  from ..utils import _cov, _dot, _stack, conditional_jit
label_desc: Use image node_id 15 for calling a global function with example usage: kde(x, circular) and returns: kde_fun, np,  np