code: def invres(r, p, k, tol=1e-3, rtype="avg"):
      """Compute b(s) and a(s) from partial fraction expansion.
  
      If `M` is the degree of numerator `b` and `N` the degree of denominator
      `a`::
  
                b(s)     b[0] s**(M) + b[1] s**(M-1) + ... + b[M]
        H(s) = ------ = ------------------------------------------
                a(s)     a[0] s**(N) + a[1] s**(N-1) + ... + a[N]
  
      then the partial-fraction expansion H(s) is defined as::
  
                 r[0]       r[1]             r[-1]
             = -------- + -------- + ... + --------- + k(s)
               (s-p[0])   (s-p[1])         (s-p[-1])
  
      If there are any repeated roots (closer together than `tol`), then H(s)
      has terms like::
  
            r[i]      r[i+1]              r[i+n-1]
          -------- + ----------- + ... + -----------
          (s-p[i])  (s-p[i])**2          (s-p[i])**n
  
      This function is used for polynomials in positive powers of s or z,
      such as analog filters or digital filters in controls engineering.  For
      negative powers of z (typical for digital filters in DSP), use `invresz`.
  
      Parameters
      ----------
      r : array_like
          Residues corresponding to the poles. For repeated poles, the residues
          must be ordered to correspond to ascending by power fractions.
      p : array_like
          Poles. Equal poles must be adjacent.
      k : array_like
          Coefficients of the direct polynomial term.
      tol : float, optional
          The tolerance for two roots to be considered equal in terms of
          the distance between them. Default is 1e-3. See `unique_roots`
          for further details.
      rtype : {'avg', 'min', 'max'}, optional
          Method for computing a root to represent a group of identical roots.
          Default is 'avg'. See `unique_roots` for further details.
  
      Returns
      -------
      b : ndarray
          Numerator polynomial coefficients.
      a : ndarray
          Denominator polynomial coefficients.
  
      See Also
      --------
      residue, invresz, unique_roots
  
      """
      r = np.atleast_1d(r)
      p = np.atleast_1d(p)
      k = np.trim_zeros(np.atleast_1d(k), "f")
  
      unique_poles, multiplicity = _group_poles(p, tol, rtype)
      factors, denominator = _compute_factors(
          unique_poles, multiplicity, include_powers=True
      )
  
      if len(k) == 0:
          numerator = 0
      else:
          numerator = np.polymul(k, denominator)
  
      for residue, factor in zip(r, factors):
          numerator = np.polyadd(numerator, residue * factor)
  
      return numerator, denominator
  
imports: import operator
  import math
  import timeit
  from scipy.spatial import cKDTree
  from .None import sigtools, dlti
  from ._upfirdn import upfirdn, _output_len, _upfirdn_modes
  from scipy import linalg, fft
  from scipy.fft._helper import _init_nd_shape_and_axes
  from scipy._lib._util import prod
  import numpy
  from scipy.special import lambertw
  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
  from ._sosfilt import _sosfilt
  import warnings
label_desc: Use image node_id 34 for calling a global function with example usage: invres(r, p, k, tol, rtype) and returns: numerator,  denominator