code: def levene(*args, center="median", proportiontocut=0.05):
      """Perform Levene test for equal variances.
  
      The Levene test tests the null hypothesis that all input samples
      are from populations with equal variances.  Levene's test is an
      alternative to Bartlett's test `bartlett` in the case where
      there are significant deviations from normality.
  
      Parameters
      ----------
      sample1, sample2, ... : array_like
          The sample data, possibly with different lengths. Only one-dimensional
          samples are accepted.
      center : {'mean', 'median', 'trimmed'}, optional
          Which function of the data to use in the test.  The default
          is 'median'.
      proportiontocut : float, optional
          When `center` is 'trimmed', this gives the proportion of data points
          to cut from each end. (See `scipy.stats.trim_mean`.)
          Default is 0.05.
  
      Returns
      -------
      statistic : float
          The test statistic.
      pvalue : float
          The p-value for the test.
  
      Notes
      -----
      Three variations of Levene's test are possible.  The possibilities
      and their recommended usages are:
  
        * 'median' : Recommended for skewed (non-normal) distributions>
        * 'mean' : Recommended for symmetric, moderate-tailed distributions.
        * 'trimmed' : Recommended for heavy-tailed distributions.
  
      The test version using the mean was proposed in the original article
      of Levene ([2]_) while the median and trimmed mean have been studied by
      Brown and Forsythe ([3]_), sometimes also referred to as Brown-Forsythe
      test.
  
      References
      ----------
      .. [1] https://www.itl.nist.gov/div898/handbook/eda/section3/eda35a.htm
      .. [2] Levene, H. (1960). In Contributions to Probability and Statistics:
             Essays in Honor of Harold Hotelling, I. Olkin et al. eds.,
             Stanford University Press, pp. 278-292.
      .. [3] Brown, M. B. and Forsythe, A. B. (1974), Journal of the American
             Statistical Association, 69, 364-367
  
      Examples
      --------
      Test whether or not the lists `a`, `b` and `c` come from populations
      with equal variances.
  
      >>> from scipy.stats import levene
      >>> a = [8.88, 9.12, 9.04, 8.98, 9.00, 9.08, 9.01, 8.85, 9.06, 8.99]
      >>> b = [8.88, 8.95, 9.29, 9.44, 9.15, 9.58, 8.36, 9.18, 8.67, 9.05]
      >>> c = [8.95, 9.12, 8.95, 8.85, 9.03, 8.84, 9.07, 8.98, 8.86, 8.98]
      >>> stat, p = levene(a, b, c)
      >>> p
      0.002431505967249681
  
      The small p-value suggests that the populations do not have equal
      variances.
  
      This is not surprising, given that the sample variance of `b` is much
      larger than that of `a` and `c`:
  
      >>> [np.var(x, ddof=1) for x in [a, b, c]]
      [0.007054444444444413, 0.13073888888888888, 0.008890000000000002]
  
      """
      if center not in ["mean", "median", "trimmed"]:
          raise ValueError(
              "center must be 'mean', 'median' or 'trimmed'."
          )
  
      k = len(args)
      if k < 2:
          raise ValueError(
              "Must enter at least two input sample vectors."
          )
      # check for 1d input
      for j in range(k):
          if np.asanyarray(args[j]).ndim > 1:
              raise ValueError("Samples must be one-dimensional.")
  
      Ni = np.empty(k)
      Yci = np.empty(k, "d")
  
      if center == "median":
          func = lambda x: np.median(x, axis=0)
      elif center == "mean":
          func = lambda x: np.mean(x, axis=0)
      else:  # center == 'trimmed'
          args = tuple(
              stats.trimboth(np.sort(arg), proportiontocut)
              for arg in args
          )
          func = lambda x: np.mean(x, axis=0)
  
      for j in range(k):
          Ni[j] = len(args[j])
          Yci[j] = func(args[j])
      Ntot = np.sum(Ni, axis=0)
  
      # compute Zij's
      Zij = [None] * k
      for i in range(k):
          Zij[i] = abs(asarray(args[i]) - Yci[i])
  
      # compute Zbari
      Zbari = np.empty(k, "d")
      Zbar = 0.0
      for i in range(k):
          Zbari[i] = np.mean(Zij[i], axis=0)
          Zbar += Zbari[i] * Ni[i]
  
      Zbar /= Ntot
      numer = (Ntot - k) * np.sum(Ni * (Zbari - Zbar) ** 2, axis=0)
  
      # compute denom_variance
      dvar = 0.0
      for i in range(k):
          dvar += np.sum((Zij[i] - Zbari[i]) ** 2, axis=0)
  
      denom = (k - 1.0) * dvar
  
      W = numer / denom
      pval = distributions.f.sf(W, k - 1, Ntot - k)  # 1 - cdf
      return LeveneResult(W, pval)
  
imports: from __future__ import annotations
  import math
  import warnings
  from collections import namedtuple
  import numpy
  from numpy import isscalar, r_, log, around, unique, asarray, zeros, arange, sort, amin, amax, atleast_1d, sqrt, array, compress, pi, exp, ravel, count_nonzero, sin, cos, arctan2, hypot
  from scipy import optimize
  from scipy import special
  from .None import statlib
  from .None import stats
  from .stats import find_repeats, _contains_nan, _normtest_finish
  from .contingency import chi2_contingency
  from .None import distributions
  from ._distn_infrastructure import rv_generic
  from ._hypotests import _get_wilcoxon_distr
label_desc: Use image node_id 29 for calling a global function with example usage: levene() and returns: LeveneResult