code: def lfilter_zi(b, a):
      """
      Construct initial conditions for lfilter for step response steady-state.
      Compute an initial state `zi` for the `lfilter` function that corresponds
      to the steady state of the step response.
      A typical use of this function is to set the initial state so that the
      output of the filter starts at the same value as the first element of
      the signal to be filtered.
      Parameters
      ----------
      b, a : array_like (1-D)
          The IIR filter coefficients. See `lfilter` for more
          information.
      Returns
      -------
      zi : 1-D ndarray
          The initial state for the filter.
      See Also
      --------
      lfilter, lfiltic, filtfilt
      Notes
      -----
      A linear filter with order m has a state space representation (A, B, C, D),
      for which the output y of the filter can be expressed as::
          z(n+1) = A*z(n) + B*x(n)
          y(n)   = C*z(n) + D*x(n)
      where z(n) is a vector of length m, A has shape (m, m), B has shape
      (m, 1), C has shape (1, m) and D has shape (1, 1) (assuming x(n) is
      a scalar).  lfilter_zi solves::
          zi = A*zi + B
      In other words, it finds the initial condition for which the response
      to an input of all ones is a constant.
      Given the filter coefficients `a` and `b`, the state space matrices
      for the transposed direct form II implementation of the linear filter,
      which is the implementation used by scipy.signal.lfilter, are::
          A = scipy.linalg.companion(a).T
          B = b[1:] - a[1:]*b[0]
      assuming `a[0]` is 1.0; if `a[0]` is not 1, `a` and `b` are first
      divided by a[0].
      """
      b = cp.atleast_1d(b)
      if b.ndim != 1:
          raise ValueError("Numerator b must be 1-D.")
      a = cp.atleast_1d(a)
      if a.ndim != 1:
          raise ValueError("Denominator a must be 1-D.")
  
      while len(a) > 1 and a[0] == 0.0:
          a = a[1:]
      if a.size < 1:
          raise ValueError(
              "There must be at least one nonzero `a` coefficient."
          )
  
      if a[0] != 1.0:
          # Normalize the coefficients so a[0] == 1.
          b = b / a[0]
          a = a / a[0]
  
      n = max(len(a), len(b))
  
      # Pad a or b with zeros so they are the same length.
      if len(a) < n:
          a = cp.r_[a, cp.zeros(n - len(a), dtype=a.dtype)]
      elif len(b) < n:
          b = cp.r_[b, cp.zeros(n - len(b), dtype=b.dtype)]
  
      IminusA = (
          cp.eye(n - 1, dtype=cp.result_type(a, b))
          - linalg.companion(a).T
      )
      B = b[1:] - a[1:] * b[0]
      # Solve zi = A*zi + B
      zi = cp.linalg.solve(IminusA, B)
  
      return zi
  
imports: import cupy
  import numpy
  from cupyx.scipy import linalg
  from ..convolution.correlate import correlate
  from ..filter_design.filter_design_utils import _validate_sos
  from ..utils.arraytools import _axis_reverse, _axis_slice, _const_ext, _even_ext, _odd_ext
  from ..utils.helper_tools import _get_max_smem, _get_max_tpb
  from ._channelizer_cuda import _channelizer
  from ._sosfilt_cuda import _sosfilt
label_desc: Use image node_id 4 for calling a global function with example usage: lfilter_zi(b, a) and returns: zi