code: def _po_ptests(
      z: pd.DataFrame,
      xsection: RegressionResults,
      test_type: Literal["Pu", "Pz"],
      trend: UnitRootTrend,
      kernel: str,
      bandwidth: int | None,
      force_int: bool,
  ) -> PhillipsOuliarisTestResults:
      nobs = z.shape[0]
      z_lead = z.iloc[1:]
      z_lag = add_trend(z.iloc[:-1], trend=trend)
      phi = np.linalg.lstsq(z_lag, z_lead, rcond=None)[0]
      xi = z_lead - np.asarray(z_lag @ phi)
  
      ker_est = KERNEL_ESTIMATORS[kernel]
      cov_est = ker_est(
          xi, bandwidth=bandwidth, center=False, force_int=force_int
      )
      cov = cov_est.cov
      # Rescale to match definition in PO
      omega = (nobs - 1) / nobs * np.asarray(cov.long_run)
  
      u = np.asarray(xsection.resid)
      if test_type.lower() == "pu":
          denom = u.T @ u / nobs
          omega21 = omega[0, 1:]
          omega22 = omega[1:, 1:]
          omega22_inv = np.linalg.inv(omega22)
          omega112 = omega[0, 0] - np.squeeze(
              omega21.T @ omega22_inv @ omega21
          )
          test_stat = nobs * float(np.squeeze(omega112 / denom))
      else:
          # returning p_z
          _z = np.asarray(z)
          if trend != "n":
              tr = add_trend(nobs=_z.shape[0], trend=trend)
              _z = _z - tr @ np.linalg.lstsq(tr, _z, rcond=None)[0]
          else:
              _z = _z - _z[:1]  # Ensure first observation is 0
          m_zz = _z.T @ _z / nobs
          test_stat = nobs * float(
              np.squeeze((omega @ np.linalg.inv(m_zz)).trace())
          )
      cv = phillips_ouliaris_cv(
          test_type, trend, z.shape[1], z.shape[0]
      )
      pval = phillips_ouliaris_pval(
          test_stat, test_type, trend, z.shape[1]
      )
      return PhillipsOuliarisTestResults(
          test_stat,
          pval,
          cv,
          order=z.shape[1],
          xsection=xsection,
          test_type=test_type,
          kernel_est=cov_est,
      )
  
imports: from __future__ import annotations
  from typing import cast
  import numpy
  import pandas
  from scipy import stats
  from statsmodels.iolib.summary import Summary
  from statsmodels.iolib.table import SimpleTable
  from statsmodels.regression.linear_model import RegressionResults
  import arch.covariance.kernel
  from arch.typing import ArrayLike1D, ArrayLike2D, Literal, UnitRootTrend
  from arch.unitroot._shared import KERNEL_ERR, KERNEL_ESTIMATORS, ResidualCointegrationTestResult, _cross_section
  from arch.unitroot.critical_values.phillips_ouliaris import CV_PARAMETERS, CV_TAU_MIN, PVAL_LARGE_P, PVAL_SMALL_P, PVAL_TAU_MAX, PVAL_TAU_MIN, PVAL_TAU_STAR
  from arch.unitroot.unitroot import TREND_DESCRIPTION
  from arch.utility.array import ensure2d
  from arch.utility.io import str_format
  from arch.utility.timeseries import add_trend
label_desc: Use image node_id 1 for calling a global function with example usage: _po_ptests(z, xsection, test_type, trend, kernel, bandwidth, force_int) and returns: PhillipsOuliarisTestResults