code: def solve_discrete_lyapunov(a, q, complex_step=False):
      r"""
      Solves the discrete Lyapunov equation using a bilinear transformation.
  
      Notes
      -----
      This is a modification of the version in Scipy (see
      https://github.com/scipy/scipy/blob/master/scipy/linalg/_solvers.py)
      which allows passing through the complex numbers in the matrix a
      (usually the transition matrix) in order to allow complex step
      differentiation.
      """
      eye = np.eye(a.shape[0], dtype=a.dtype)
      if not complex_step:
          aH = a.conj().transpose()
          aHI_inv = np.linalg.inv(aH + eye)
          b = np.dot(aH - eye, aHI_inv)
          c = 2 * np.dot(np.dot(np.linalg.inv(a + eye), q), aHI_inv)
          return solve_sylvester(b.conj().transpose(), b, -c)
      else:
          aH = a.transpose()
          aHI_inv = np.linalg.inv(aH + eye)
          b = np.dot(aH - eye, aHI_inv)
          c = 2 * np.dot(np.dot(np.linalg.inv(a + eye), q), aHI_inv)
          return solve_sylvester(b.transpose(), b, -c)
  
imports: import numpy
  from scipy.linalg import solve_sylvester
  import pandas
  from statsmodels.compat.pandas import Appender
  from statsmodels.tools.data import _is_using_pandas
  from scipy.linalg.blas import find_best_blas_type
  from .None import _initialization, _representation, _kalman_filter, _kalman_smoother, _simulation_smoother, _cfa_simulation_smoother, _tools
label_desc: Use image node_id 6 for calling a global function with example usage: solve_discrete_lyapunov(a, q, complex_step) and returns: solve_sylvester, solve_sylvester