code: def pacf_burg(
      x: ArrayLike1D, nlags: int | None = None, demean: bool = True
  ) -> tuple[np.ndarray, np.ndarray]:
      """
      Calculate Burg"s partial autocorrelation estimator.
  
      Parameters
      ----------
      x : array_like
          Observations of time series for which pacf is calculated.
      nlags : int, optional
          Number of lags to return autocorrelation for. If not provided,
          uses min(10 * np.log10(nobs), nobs - 1).
      demean : bool, optional
          Flag indicating to demean that data. Set to False if x has been
          previously demeaned.
  
      Returns
      -------
      pacf : ndarray
          Partial autocorrelations for lags 0, 1, ..., nlag.
      sigma2 : ndarray
          Residual variance estimates where the value in position m is the
          residual variance in an AR model that includes m lags.
  
      See Also
      --------
      statsmodels.tsa.stattools.pacf
          Partial autocorrelation estimation.
      statsmodels.tsa.stattools.pacf_yw
           Partial autocorrelation estimation using Yule-Walker.
      statsmodels.tsa.stattools.pacf_ols
          Partial autocorrelation estimation using OLS.
  
      References
      ----------
      .. [1] Brockwell, P.J. and Davis, R.A., 2016. Introduction to time series
          and forecasting. Springer.
      """
      x = array_like(x, "x")
      if demean:
          x = x - x.mean()
      nobs = x.shape[0]
      p = (
          nlags
          if nlags is not None
          else min(int(10 * np.log10(nobs)), nobs - 1)
      )
      p = max(p, 1)
      if p > nobs - 1:
          raise ValueError("nlags must be smaller than nobs - 1")
      d = np.zeros(p + 1)
      d[0] = 2 * x.dot(x)
      pacf = np.zeros(p + 1)
      u = x[::-1].copy()
      v = x[::-1].copy()
      d[1] = u[:-1].dot(u[:-1]) + v[1:].dot(v[1:])
      pacf[1] = 2 / d[1] * v[1:].dot(u[:-1])
      last_u = np.empty_like(u)
      last_v = np.empty_like(v)
      for i in range(1, p):
          last_u[:] = u
          last_v[:] = v
          u[1:] = last_u[:-1] - pacf[i] * last_v[1:]
          v[1:] = last_v[1:] - pacf[i] * last_u[:-1]
          d[i + 1] = (1 - pacf[i] ** 2) * d[i] - v[i] ** 2 - u[-1] ** 2
          pacf[i + 1] = 2 / d[i + 1] * v[i + 1 :].dot(u[i:-1])
      sigma2 = (
          (1 - pacf**2) * d / (2.0 * (nobs - np.arange(0, p + 1)))
      )
      pacf[0] = 1  # Insert the 0 lag partial autocorrel
  
      return pacf, sigma2
  
imports: from __future__ import annotations
  from statsmodels.compat.numpy import lstsq
  from statsmodels.compat.pandas import deprecate_kwarg
  from statsmodels.compat.python import Literal, lzip
  from statsmodels.compat.scipy import _next_regular
  from typing import Union
  import warnings
  import numpy
  from numpy.linalg import LinAlgError
  import pandas
  from scipy import stats
  from scipy.interpolate import interp1d
  from scipy.signal import correlate
  from statsmodels.regression.linear_model import OLS, yule_walker
  from statsmodels.tools.sm_exceptions import CollinearityWarning, InfeasibleTestError, InterpolationWarning, MissingDataError, ValueWarning
  from statsmodels.tools.tools import Bunch, add_constant
  from statsmodels.tools.validation import array_like, bool_like, dict_like, float_like, int_like, string_like
  from statsmodels.tsa._bds import bds
  from statsmodels.tsa._innovations import innovations_algo, innovations_filter
  from statsmodels.tsa.adfvalues import mackinnoncrit, mackinnonp
  from statsmodels.tsa.tsatools import add_trend, lagmat, lagmat2ds
label_desc: Use image node_id 7 for calling a global function with example usage: pacf_burg(x, nlags, demean) and returns: pacf,  sigma2