code: def _kpss_autolag(resids, nobs):
      """
      Computes the number of lags for covariance matrix estimation in KPSS test
      using method of Hobijn et al (1998). See also Andrews (1991), Newey & West
      (1994), and Schwert (1989). Assumes Bartlett / Newey-West kernel.
      """
      covlags = int(np.power(nobs, 2.0 / 9.0))
      s0 = np.sum(resids**2) / nobs
      s1 = 0
      for i in range(1, covlags + 1):
          resids_prod = np.dot(resids[i:], resids[: nobs - i])
          resids_prod /= nobs / 2.0
          s0 += resids_prod
          s1 += i * resids_prod
      s_hat = s1 / s0
      pwr = 1.0 / 3.0
      gamma_hat = 1.1447 * np.power(s_hat * s_hat, pwr)
      autolags = int(gamma_hat * np.power(nobs, pwr))
      return autolags
  
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 22 for calling a global function with example usage: _kpss_autolag(resids, nobs) and returns: autolags