code: def levene_constant_variance(
      data: pd.Series, confidence_level: float = 0.05
  ) -> TestResult:
      """Levene test for constant variances, tests the null hypothesis that all input samples are
      from populations with equal variances.
  
      Args:
          data (pd.Series): Time series.
          confidence_level (float): Confidence level for rejecting the null hypothesis.
  
      Returns:
          TestResult: test name, p-value, null hypothesis, reject?, confidence level and details.
  
      See Also:
          https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.levene.html
      """
      ser_clean = data
      if np.isnan(data).any():
          ser_clean = data.fillna(method="bfill").fillna(method="ffill")
          warnings.warn("Found and removed N/A values.", UserWarning)
  
      try:
          freq = freq_to_period(data.index.inferred_freq)
          width = freq if freq > 1 else 10
          n_segs = len(data) // width
      except (ValueError, AttributeError):
          n_segs = 2
          width = len(data) // n_segs
  
      sample_groups = ser_clean.values[: n_segs * width].reshape(
          n_segs, width
      )
      t_statistic, p_value = scipy.stats.levene(*sample_groups)
      initial_hypothesis = (
          f"Variance is constant between {n_segs} groups"
      )
      outcome_specifics = {"t_statistic": float(t_statistic)}
      reject_h0 = bool(p_value < confidence_level)
      result = TestResult(
          test="Levene",
          p_value=float(p_value),
          null_hypothesis=initial_hypothesis,
          reject_null_hypothesis=reject_h0,
          details=outcome_specifics,
          confidence_level=confidence_level,
      )
  
      return result
  
file_path: tslumen/tslumen/profile/stat_tests.py
imports: from typing import Dict, Any, Optional
  from dataclasses import dataclass
  import math
  import warnings
  import numpy
  import pandas
  import scipy
  import statsmodels.stats.api
  from statsmodels.tsa.tsatools import freq_to_period
  from statsmodels.tsa.stattools import acf, adfuller, kpss
  from tslumen.profile.base import ProfilingFunction, _DCDict
  from tslumen.misc import repr_html
label_desc: Use image node_id 1 for calling a global function with example usage: levene_constant_variance(data, confidence_level) and returns: result