code: def _root_test(model, ic, trace):
      """
      Check the roots of the new model, and set IC to inf if the roots are
      near non-invertible. This is a little bit different than how Rob does it:
      https://github.com/robjhyndman/forecast/blob/master/R/newarima2.R#L780
      In our test, we look directly at the inverse roots to see if they come
      anywhere near the unit circle border
      """
      max_invroot = 0
      p, d, q = model.order
      P, D, Q, m = model.seasonal_order
  
      if p + P > 0:
          max_invroot = max(0, *np.abs(1 / model.arroots()))
      if q + Q > 0 and np.isfinite(ic):
          max_invroot = max(0, *np.abs(1 / model.maroots()))
  
      if max_invroot > 1 - 1e-2:
          ic = np.inf
          if trace > 1:
              print(
                  "Near non-invertible roots for order "
                  "(%i, %i, %i)(%i, %i, %i, %i); setting score to inf (at "
                  "least one inverse root too close to the border of the "
                  "unit circle: %.3f)"
                  % (p, d, q, P, D, Q, m, max_invroot)
              )
      return ic
  
imports: from numpy.linalg import LinAlgError
  import numpy
  from datetime import datetime
  from joblib import Parallel, delayed
  from sklearn.utils import check_random_state
  import abc
  import functools
  import time
  import warnings
  import traceback
  from .arima import ARIMA
  from ..warnings import ModelFitWarning
  from ._context import ContextType, ContextStore
  from .None import _validation
  from ..compat import statsmodels
label_desc: Use image node_id 1 for calling a global function with example usage: _root_test(model, ic, trace) and returns: ic