code: def sosfilt_zi(sos):
      """
      Construct initial conditions for sosfilt for step response steady-state.
  
      Compute an initial state `zi` for the `sosfilt` 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
      ----------
      sos : array_like
          Array of second-order filter coefficients, must have shape
          ``(n_sections, 6)``. See `sosfilt` for the SOS filter format
          specification.
  
      Returns
      -------
      zi : ndarray
          Initial conditions suitable for use with ``sosfilt``, shape
          ``(n_sections, 2)``.
  
      See Also
      --------
      sosfilt, zpk2sos
  
      Notes
      -----
      .. versionadded:: 0.16.0
  
      Examples
      --------
      Filter a rectangular pulse that begins at time 0, with and without
      the use of the `zi` argument of `scipy.signal.sosfilt`.
  
      >>> from scipy import signal
      >>> import matplotlib.pyplot as plt
  
      >>> sos = signal.butter(9, 0.125, output='sos')
      >>> zi = signal.sosfilt_zi(sos)
      >>> x = (np.arange(250) < 100).astype(int)
      >>> f1 = signal.sosfilt(sos, x)
      >>> f2, zo = signal.sosfilt(sos, x, zi=zi)
  
      >>> plt.plot(x, 'k--', label='x')
      >>> plt.plot(f1, 'b', alpha=0.5, linewidth=2, label='filtered')
      >>> plt.plot(f2, 'g', alpha=0.25, linewidth=4, label='filtered with zi')
      >>> plt.legend(loc='best')
      >>> plt.show()
  
      """
      sos = np.asarray(sos)
      if sos.ndim != 2 or sos.shape[1] != 6:
          raise ValueError("sos must be shape (n_sections, 6)")
  
      n_sections = sos.shape[0]
      zi = np.empty((n_sections, 2))
      scale = 1.0
      for section in range(n_sections):
          b = sos[section, :3]
          a = sos[section, 3:]
          zi[section] = scale * lfilter_zi(b, a)
          # If H(z) = B(z)/A(z) is this section's transfer function, then
          # b.sum()/a.sum() is H(1), the gain at omega=0.  That's the steady
          # state value of this section's step response.
          scale *= b.sum() / a.sum()
  
      return zi
  
imports: from __future__ import division, print_function, absolute_import
  import operator
  import threading
  import sys
  import timeit
  from scipy.spatial import cKDTree
  from .None import sigtools, dlti
  from ._upfirdn import upfirdn, _output_len
  from scipy._lib.six import callable
  from scipy._lib._version import NumpyVersion
  from scipy import fftpack, linalg
  from scipy.fftpack.helper import _init_nd_shape_and_axes_sorted
  from numpy import allclose, angle, arange, argsort, array, asarray, atleast_1d, atleast_2d, cast, dot, exp, expand_dims, iscomplexobj, mean, ndarray, newaxis, ones, pi, poly, polyadd, polyder, polydiv, polymul, polysub, polyval, product, r_, ravel, real_if_close, reshape, roots, sort, take, transpose, unique, where, zeros, zeros_like
  import numpy
  import math
  from scipy.special import factorial
  from .windows import get_window
  from ._arraytools import axis_slice, axis_reverse, odd_ext, even_ext, const_ext
  from .filter_design import cheby1, _validate_sos
  from .fir_filter_design import firwin
label_desc: Use image node_id 37 for calling a global function with example usage: sosfilt_zi(sos) and returns: zi